Hi Kunal and Jari,

Thanks for this bug discovery ! :)
You're right, the cookie should not get URL encoded ...
I'll correct that right away, add a unit test and put it in CVS so that you
can get it right away.

Thanks
Vincent

----- Original Message -----
From: "Vaishnav, Kunal" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, June 27, 2001 5:59 PM
Subject: RE: Is this a bug in Cactus???


> Exactly!. I figured out that what I will do is to make a HttpClientHelper
> and see to it that addCookies method is over-rided.
> This means I will have to chg the file. But then how do I make sure that
> only this file is called when I call the addCookie method..
>
>
>
> -----Original Message-----
> From: Jari Worsley [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 27, 2001 11:05 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Is this a bug in Cactus???
>
>
> "Vaishnav, Kunal" wrote:
> >
> > Hello All,
> >   I have a unique error when I am working with JUnit and Cactus. I am
> > testing some of my APIs for login stuff. Now
> > to login, I need to pass encrypted cookies. Fine that is ok. What I am
> > passing in the cookies is a pipe of the username and password. (eg
> > username|password). Cactus seems to
> > be converting the "|" to %7C. I wanted to know how I can avoid this.
> > If it gets converted to %7C, it gives me a number format excpetion and
so
> > on...
> > Is there any workaround this? Is this a bug in Cactus because of which
> this
> > is happening?.
>
> This does look like a bug.
>
> The HttpClientHelper class appears to URLEncode the cookies like so:
> (see private addCookies method, round about line 230).
>
>         while (keys.hasMoreElements()) {
>             String key = (String)keys.nextElement();
>             String value = (String)theRequest.getCookieValue(key);
>             cookieString.append(';');
>             cookieString.append(URLEncoder.encode(key));
>             cookieString.append('=');
>             cookieString.append(URLEncoder.encode(value));
>             cookieString.append(value);
>         }
> before using
> setRequestProperty("Cookie", cookieString.toString());
>
> if you change to :
>         while (keys.hasMoreElements()) {
>             String key = (String)keys.nextElement();
>             String value = (String)theRequest.getCookieValue(key);
>             cookieString.append(';');
>             cookieString.append(key);
>             cookieString.append('=');
>             cookieString.append(value);
>         }
>
> then the cookie string isn't URLEncoded then it appears to work ok, and
> the Cookie values come through ok on the server.
>
> HttpURLConnection must do the encoding for you, in which case your
> cookie is being encoded twice! :)
>
>
> Anyone care to comment? and if this is a bug then fix in the source?
>
> Vincent?
>
> Jari
>
>
> >
> > Thx.
> > Kunal.
>
> --
> Jari Worsley
> Senior Programmer
> Hyperlink Interactive Ltd
>

Reply via email to