hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Johnson <e...@tibco.com>
Subject Re: [HttpClient] reuse connections
Date Tue, 26 Aug 2003 19:28:45 GMT

A "true" response from "isStale()" tends to mean that if HttpClient did 
go ahead and re-use the connection, the request would fail, usually upon 
reading the response from the server. This would be unfortunate for you, 
particularly with regards to "PUT", because then you would not be in any 
position to know whether the server actually received the entire PUT 
prior to losing the connection.

If I had to guess, what you're seeing is either a simple timing issue, 
in that some servers simply close a connection after a certain amount of 
idle time, or that the server to which you're connecting closes a 
connection after processing a PUT request. In the latter case, ideally 
the server would be sending back a "Connection: close" header to let 
HttpClient know that this is what it is doing. You might turn on the 
wire logging to see if this is the case.

HttpClient's particular behavior here stems from Java's inability to 
detect closed connections prior to JRE 1.4. The only way to determine 
whether a connection is closed is to actually read or write to the 
connection, which is exactly what isStale() does.


Andreas Probst wrote:

>Hi all,
>I'd like to reuse open connections in successive calls to the 
>same instance of HttpClient with everytime newly created 
>instances of HttpMethod (of course to the same server).
>>From my tests I could see, that successive GETs use the same 
>connection. A following PUT uses the same connection too. 
>However, successive PUTs always open a new connection, as the 
>old one is supposed to be stale. I debugged through the method 
>isStale() but don't really understand the logic and especially 
>the behaviour (with InterruptedIOException) behind it.
>Should HttpClient be able to reuse connections in successive 
>PUTs? What should I do to persuade HttpClient to do so?
>Thanks in advance,
>To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org

View raw message