hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cordes, Hans-Dieter" <hdcor...@emea.att.com>
Subject RE: HttpClient: Release all resources due to a Thread.interrupt
Date Mon, 23 May 2005 08:33:32 GMT
Oleg,

many thanks for your answer. I have already played a little bit with the timeout, and I have
found that it is an approach that I can work with. However, thanks for your reminder to the
"httpget.releaseConnection()" call which I had forgotten.

Regards,
	Hans-Dieter Cordes

-----Original Message-----
From: Oleg Kalnichevski [mailto:olegk@apache.org]
Sent: Samstag, 21. Mai 2005 13:04
To: HttpClient User Discussion
Subject: Re: HttpClient: Release all resources due to a Thread.interrupt


Hans-Dieter,

A trivial socket read timeout will do. Just make sure you always release
connection back to the manager regardless whether the request succeeds
or fails

GetMethod httpget = new GetMethod("/whatever");
try {
  httpclient.executeMethod(httpget);
  // do stuff
} finally {
  httpget.releaseConnection();
}

Alternatively, if you are using HttpClient 3.0, you may want to call
HttpMethod#abort to close the underlying socket

Oleg

On Fri, 2005-05-20 at 16:01 +0200, Cordes, Hans-Dieter wrote:
> Hello,
> 
> I need some assistance with the following problem:
> 
> I have a thread X that will be allowed to live only for a specified amount of time. In
that thread I have an HttpClient object that I use to send a POST to another server machine.
Now I want to make sure that when my thread X is interrupted, because its time-out has expired,
I am able to release all resources of the HttpClient object. What do I have to do?
> 
> I would think that basically I should simply close the corresponding socket via the HttpConnection
object that HttpClient uses. But I have not found a way to get this HttpConnection object
given that I have references to HttpClient and PostMethod. (Perhaps I should first close/release
the request/response I/O channels, but when the socket goes down, this should be done automatically.
And perhaps I could also use the HttpClient.setTimeout method?)
> 
> Many thanks in advance for your help.
> 
> Regards,
> 	Hans-Dieter Cordes
> 
> ---------------------------------------------------------------------
> 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


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