hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <ROLWE...@de.ibm.com>
Subject Re: Cookie problem
Date Wed, 15 Dec 2004 08:13:01 GMT
Hello Marcin,

somewhere down the road, it has been made possible
to set the cookie header manually:
http://issues.apache.org/bugzilla/show_bug.cgi?id=24081

I think that is just what you need.

cheers,
  Roland




madey22@interia.pl 
15.12.2004 01:19
Please respond to
"HttpClient User Discussion"


To
httpclient-user@jakarta.apache.org
cc

Subject
Cookie problem







Hello,
I use HttpClient 2.0.2
I have a little problem with cookies.
I write a servlet, to work as a kind of proxy to a different http server.
So I take my HttpServletRequest, rewrite it's method, and header to
a HttpClient and execute that method.
After that, I take a response from method, rewrite header to 
HttpServletResponse and
rewrite also a body (binary). And everythink works fine but I have a 
little problem with cookies.
When a cookie came with header from HttpClient (Set-cookie), it is just 
rewritten to HttpServletResponse
and I can see in my browser then that cookie with proper value.
When I try to sent a cookie to HttpClient from HttpServletrequest:
I know that it can't be rewritten with header (I've found that in 
archive).
So I write:

String url = "http://www.my.address.org/"

HostConfiguration config = new HostConfiguration();
config.setHost(url, 80);
HttpClient client = new HttpClient();
HttpState state = client.getState();
Cookie myCookie = new Cookie(url, some_name, some_value);
state.addCookie(myCookie);

PostMethod method = new PostMethod(url);  //I use post and get method
// add header, and parameters here

client.executeMethod(config, method, state);

and when I look at the things which where sent to the server i can see
that there are no cookie header at all. Rest of the package looks ok 
(there is rest of the
headers and protocol and everything as it should be).
The name and value i take from a cookie which
where sent to me by HttpServletRequest, and I have checked them, there are 
ok.
What is wrong? What is the correct way to add a cookie to request?

Marcin Piatek

----------------------------------------------------------------------
Startuj z INTERIA.PL!!! >>> http://link.interia.pl/f1837


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



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message