You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Derek Alexander <da...@ukgateway.net> on 2003/07/19 16:04:06 UTC

HttpClient - Want all cookies in a single header line

Hi,

I'm trying to make an HTTP GET request with all the Cookies on one header
line.
For some reason the request is built with each cookie on a separate line.

i.e., I want:

Cookie: foo=1; baa=2

but I am getting

Cookie: foo=1
Cookie: baa=2

I've looked at the source for HttpMethodBase where I saw that this depends
on whether it is in strictMode. So, I set it to strictMode first.

Doesn't seem to make any difference though.

Here's my code. Can someone tell me where I've gone wrong.

// ...
HttpClient client = new HttpClient();
HttpState state = client.getState();
state.setCookiePolicy(CookiePolicy.COMPATIBILITY);
state.addCookie(new Cookie("192.168.0.1","foo","1","/",null,false));
state.addCookie(new Cookie("192.168.0.1","baa","2","/",null,false));
GetMethod method = new GetMethod("http://192.168.0.1/index.html");
method.setStrictMode(true);
int statusCode = client.executeMethod(method);
// ...


Hope someone can help.

Thanks.


RE: HttpClient - Want all cookies in a single header line

Posted by Derek Alexander <da...@ukgateway.net>.
Don't spend any time on this.

I got the answer from the Sun Java Forums.

Apparently the strictMode setting is reset by the client so I
had to set it there.

Reagrds.

-----Original Message-----
From: Derek Alexander [mailto:dalexander@ukgateway.net]
Sent: 19 July 2003 15:04
To: commons-user@jakarta.apache.org
Subject: HttpClient - Want all cookies in a single header line


Hi,

I'm trying to make an HTTP GET request with all the Cookies on one header
line.
For some reason the request is built with each cookie on a separate line.

i.e., I want:

Cookie: foo=1; baa=2

but I am getting

Cookie: foo=1
Cookie: baa=2

I've looked at the source for HttpMethodBase where I saw that this depends
on whether it is in strictMode. So, I set it to strictMode first.

Doesn't seem to make any difference though.

Here's my code. Can someone tell me where I've gone wrong.

// ...
HttpClient client = new HttpClient();
HttpState state = client.getState();
state.setCookiePolicy(CookiePolicy.COMPATIBILITY);
state.addCookie(new Cookie("192.168.0.1","foo","1","/",null,false));
state.addCookie(new Cookie("192.168.0.1","baa","2","/",null,false));
GetMethod method = new GetMethod("http://192.168.0.1/index.html");
method.setStrictMode(true);
int statusCode = client.executeMethod(method);
// ...


Hope someone can help.

Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org