hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sharma, Siddharth" <Siddharth.Sha...@Staples.com>
Subject RE: Concurrency question
Date Sat, 10 Jun 2006 14:30:43 GMT
That certainly does. Thanks Roland. Appreciate it.

So, is it safe to assume that one HttpClient instance can be reused for all
clients for all remote services (using the following method):

public int executeMethod(HostConfiguration hostconfig,
                         HttpMethod method,
                         HttpState state)
                  throws IOException,
                         HttpException


-----Original Message-----
From: Roland Weber [mailto:http-async@dubioso.net] 
Sent: Saturday, June 10, 2006 1:26 AM
To: HttpClient User Discussion
Subject: Re: Concurrency question

Hello Sidd,

> Since the connection needs to be conversational, we need to maintain
> cookies. I noticed the class that wraps this is HttpState.
> HttpClient wraps this class.

HttpClient wraps only the default HttpState object, for those that
don't need to maintain separate states.

> So I declared HttpClient as static to reuse it for all requests to all
> remote services. And I passed it the MultiThreadedHttpConnectionManager
for
> handling concurrent requests. But I cannot figure out how to set HttpState
> in a thread-safe manner.

The trick is to choose the appropriate executeRequest(...) method.
This one will use the HttpState you pass as the third argument:

http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/http
client/HttpClient.html#executeMethod(org.apache.commons.httpclient.HostConfi
guration,%20org.apache.commons.httpclient.HttpMethod,%20org.apache.commons.h
ttpclient.HttpState)

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

---------------------------------------------------------------------
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