Hello,

you need one HttpState for each thread, since the cookies
are stored there. Creating a new state for each request will
not work, unless the threads manage the cookies themselves.

The HttpClient is associated with a connection pool. If
you require independently configured connection pools
for each thread, you have to create multiple HttpClient
objects. Otherwise, one HttpClient with MultiThreadedHCM
is ok.

hope that helps,
  Roland






Cabbar Duzayak <[EMAIL PROTECTED]>
12.05.2004 09:32
Please respond to "Commons HttpClient Project"
 
        To:     [EMAIL PROTECTED]
        cc: 
        Subject:        HttpClient initialization, when/where?


Hi,

I will be writing a gateway which will invoke URLs in
behalf of several threads and they will return the
content. Each thread needs to invoke different URLs
with different context (cookies, etc).

It looks like right way of doing this is to
instantiate the HttpClient once with
MultiThreadedHttpConnectionManager and each thread
will use httpClient.executeMethod on this HttpClient
instance. Or the other alternative is to instantiate
one object for each thread, and keep calling
executeMethods on them. 

However, since you can set the state of the
HttpClient, I was wondering if I can use the
HttpClient for iterative http invocations with
different contexts? I mean, is there an in-memory
state other than the HttpState that is preserved
between these invocations? Would it be enough to
create an HttpState and GetMethod for each call, and
set it before calling executeMethod? 

Shortly, what is the optimum mechanism for this
functionality?

TIA...



 
 
__________________________________
Do you Yahoo!?
Yahoo! Movies - Buy advance tickets for 'Shrek 2'
http://movies.yahoo.com/showtimes/movie?mid=1808405861 

---------------------------------------------------------------------
To unsubscribe, e-mail: 
[EMAIL PROTECTED]
For additional commands, e-mail: 
[EMAIL PROTECTED]


Reply via email to