You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Mark R. Diggory" <md...@latte.harvard.edu> on 2004/03/03 17:50:20 UTC

HttpClient and Concurrent requests to the same host.

I have an instance of HttpClient which I think I'm experiencing a race 
condition with.

I make one GetMethod request to a resource, as I'm parsing the 
InputStream into xml, I'm also making secondary GetMethod requests to 
URI's that reside on the same host. During each secondary request, I 
properly close the InputStream and call method.releaseConnection() to 
return the connection to the pool.

Unfortunately, calling these methods seems to also close down the 
initial parent stream which should still contain content and be readable 
after the secondary connection is closed.

Should I be using the multithreaded HostConfiguration here?

-Mark

-- 
Mark Diggory
Software Developer
Harvard MIT Data Center
http://www.hmdc.harvard.edu

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


Re: HttpClient and Concurrent requests to the same host.

Posted by "Mark R. Diggory" <md...@latte.harvard.edu>.
Yep, thats the solution. Thanks a bunch.

Michael Becke wrote:

> Hi Mark,
> 
> By default HttpClient makes use of the SimpleHttpConnectionManager. This 
> connection manager only supports one request at a time.  Each request, 
> including the response, must be fully complete before the next begins.  
> Sounds like the MultiThreadedHttpConnectionManager might be more 
> appropriate for you 
> <http://jakarta.apache.org/commons/httpclient/threading.html>.
> 
> Mike
> 
> Mark R. Diggory wrote:
> 
>> I have an instance of HttpClient which I think I'm experiencing a race 
>> condition with.
>>
>> I make one GetMethod request to a resource, as I'm parsing the 
>> InputStream into xml, I'm also making secondary GetMethod requests to 
>> URI's that reside on the same host. During each secondary request, I 
>> properly close the InputStream and call method.releaseConnection() to 
>> return the connection to the pool.
>>
>> Unfortunately, calling these methods seems to also close down the 
>> initial parent stream which should still contain content and be 
>> readable after the secondary connection is closed.
>>
>> Should I be using the multithreaded HostConfiguration here?
>>
>> -Mark
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> commons-httpclient-dev-help@jakarta.apache.org
> 

-- 
Mark Diggory
Software Developer
Harvard MIT Data Center
http://www.hmdc.harvard.edu

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


Re: HttpClient and Concurrent requests to the same host.

Posted by Michael Becke <be...@u.washington.edu>.
Hi Mark,

By default HttpClient makes use of the SimpleHttpConnectionManager. 
This connection manager only supports one request at a time.  Each 
request, including the response, must be fully complete before the next 
begins.  Sounds like the MultiThreadedHttpConnectionManager might be 
more appropriate for you 
<http://jakarta.apache.org/commons/httpclient/threading.html>.

Mike

Mark R. Diggory wrote:
> I have an instance of HttpClient which I think I'm experiencing a race 
> condition with.
> 
> I make one GetMethod request to a resource, as I'm parsing the 
> InputStream into xml, I'm also making secondary GetMethod requests to 
> URI's that reside on the same host. During each secondary request, I 
> properly close the InputStream and call method.releaseConnection() to 
> return the connection to the pool.
> 
> Unfortunately, calling these methods seems to also close down the 
> initial parent stream which should still contain content and be readable 
> after the secondary connection is closed.
> 
> Should I be using the multithreaded HostConfiguration here?
> 
> -Mark
> 

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