hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <http-as...@dubioso.net>
Subject Re: How to shutdown response from HttpClient
Date Sat, 10 Dec 2005 21:10:53 GMT
Hi Saminda,

Saminda Abeyruwan wrote:

> Hi devs,
> Is there a way to shutdown the response for a request in HttpClient. For
> example think about the fire-and-forget scenario of WSDL 2.0 defintion.
> I'm working in the Axis2 project, and as the transport we use
> HttpClient. We found it very defficult to implement  fire-and-forget
> becase HttpClient is waiting for a response.

The problem is that HttpClient has to know when to release the connection.
If the underlying socket is closed before the data is completely sent to
the server, then the server might not be able to process the request.
Even if your scenario is fire-and-forget, you still want the message to
have a chance of arriving at the other side :-)

Oleg's suggestion to use HttpMethod.abort() requires you to run a thread
that calls abort(), and that thread has to guess when it is safe to
abort the call.

Odi's idea of subclassing PostMethod to a PostNoReplyMethod probably
brings you closer to what you want to achieve. Make sure to return true
from shouldCloseConnection() so the connection won't be kept alive.
Then override HttpMethodBase.readResponse, which is called from
HttpMethodBase.execute, to block only until you are sure the request
has been sent to the server. Maybe you can/have to screw around with
the underlying socket. Initialize a fake statusLine before returning.

hope that helps,

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

View raw message