I was doing a normal POST type request. This added the correct content
header just a few lines above the code I changed in io.js:

headers[*"Content-Type"*] = *"application/x-www-form-urlencoded"*;


This content header was then being escaped, which caused the / char to get
translated. This caused an exception on the server saying the header content
could not be recognized. I am completely up for a different way to fix it if
you have one though.

Also, if you are concerned about the spec I could change this so there are
two methods, encodeValues and encodeValuesWithoutEscaping (or something, you
get the idea) that both use a third helper method to eliminate duplication.
I can make that refactoring if the solution that is in the code seems valid.


Thanks.

- Cassie


On Wed, Feb 20, 2008 at 7:17 PM, Kevin Brown <[EMAIL PROTECTED]> wrote:

> I'm not sure I follow here -- we already decode headers on the server. Not
> encoding them cause problems (any = or & in headers will break this; & is
> not common in headers, but = is). I'm also not really keen on adding a
> parameter (even an optional one) to a method that is in the spec. It might
> cause misuse that we'll have to address in the future.
>
> What headers were you trying to send that the proxy wasn't passing
> through?
> It sounds like there might be a bug in the proxy, not gadgets.io.
>
> On Wed, Feb 20, 2008 at 7:06 PM, <[EMAIL PROTECTED]> wrote:
>
> > Author: doll
> > Date: Wed Feb 20 19:06:33 2008
> > New Revision: 629680
> >
> > URL: http://svn.apache.org/viewvc?rev=629680&view=rev
> > Log:
> > Fix for io.js : header params are no longer escaped which enables posts
> to
> > work. Also added hasOwnProperty to caja-proof the code.
> >
> >
> > Modified:
> >    incubator/shindig/trunk/features/core.io/io.js
> >
> > Modified: incubator/shindig/trunk/features/core.io/io.js
> > URL:
> >
> http://svn.apache.org/viewvc/incubator/shindig/trunk/features/core.io/io.js?rev=629680&r1=629679&r2=629680&view=diff
> >
> >
> ==============================================================================
> > --- incubator/shindig/trunk/features/core.io/io.js (original)
> > +++ incubator/shindig/trunk/features/core.io/io.js Wed Feb 20 19:06:33
> > 2008
> > @@ -184,7 +184,7 @@
> >       var postData = {
> >         url: url,
> >         httpMethod : params.METHOD || "GET",
> > -        headers: gadgets.io.encodeValues(headers),
> > +        headers: gadgets.io.encodeValues(headers, false),
> >         postData : params.POST_DATA || "",
> >         authz : auth || "",
> >         st : st || ""
> > @@ -197,22 +197,26 @@
> >      * (key=value&amp;...)
> >      *
> >      * @param {Object} fields The post fields you wish to encode
> > +     * @param {Boolean} opt_noEscaping An optional parameter specifying
> > whether
> > +     *     to turn off escaping of the parameters. Defaults to false.
> >      * @return {String} The processed post data in www-form-urlencoded
> > format.
> >      *
> >      * @member gadgets.io
> >      */
> > -    encodeValues : function (fields) {
> > +    encodeValues : function (fields, opt_noEscaping) {
> > +      var escape = !opt_noEscaping;
> > +
> >       var buf = [];
> >       var first = false;
> > -      for (var i in fields) {
> > +      for (var i in fields) if (fields.hasOwnProperty(i)) {
> >         if (!first) {
> >           first = true;
> >         } else {
> >           buf.push("&");
> >         }
> > -        buf.push(encodeURIComponent(i));
> > +        buf.push(escape ? encodeURIComponent(i) : i);
> >         buf.push("=");
> > -        buf.push(encodeURIComponent(fields[i]));
> > +        buf.push(escape ? encodeURIComponent(fields[i]) : fields[i]);
> >       }
> >       return buf.join("");
> >     },
> >
> >
> >
>
>
> --
> ~Kevin
>
> If you received this email by mistake, please delete it, cancel your mail
> account, destroy your hard drive, silence any witnesses, and burn down the
> building that you're in.
>

Reply via email to