hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <http-as...@dubioso.net>
Subject Re: managing cookies in threads
Date Wed, 05 Jul 2006 17:58:29 GMT
> Okay, so I should keep cookies in my own code and pass them to executeMethod
> either with using HttpState object or with adding cookie directly with
> addcookie method.

No. You should let HttpClient handle cookies in HttpState. But your code
needs to make sure that there is a separate HttpState for each session, or
each set of cookies you want to maintain.

> Could you please explain why you are using HostConfiguration
> and why it needs to be created for each thread?

The HttpClient method that allows for passing an HttpState also expects
a HostConfiguration:
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/HttpClient.html#executeMethod(org.apache.commons.httpclient.HostConfiguration,%20org.apache.commons.httpclient.HttpMethod,%20org.apache.commons.httpclient.HttpState)

The HostConfiguration object could get updated during method execution,
in particular if the method director has to follow a redirect. That's
why you don't want different threads to share HttpConfiguration objects.

hope that helps,
  Roland

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


Mime
View raw message