You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Saminda Abeyruwan <sa...@opensource.lk> on 2005/12/08 05:14:24 UTC

How to shutdown response from HttpClient

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.

If i can shutdown the response then that would be a huge advantage of 
implementing fire-and-forget. { This is one alternative we have. }

Pls be kind enough to provide me with a solution.

Thanks

Saminda


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


Re: How to shutdown response from HttpClient

Posted by Roland Weber <ht...@dubioso.net>.
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,
  Roland


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


Re: How to shutdown response from HttpClient

Posted by Ortwin Glück <od...@odi.ch>.
Hi Saminda,

You could probably subclass a POST method (you are using POST, right?) 
so it does not expects a response and HttpClient does not wait for one.

Odi

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.
> 
> If i can shutdown the response then that would be a huge advantage of 
> implementing fire-and-forget. { This is one alternative we have. }
> 
> Pls be kind enough to provide me with a solution.
> 
> Thanks
> 
> Saminda
> 


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


Re: How to shutdown response from HttpClient

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, Dec 08, 2005 at 10:14:24AM +0600, 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.
> 
> If i can shutdown the response then that would be a huge advantage of 
> implementing fire-and-forget. { This is one alternative we have. }
> 
> Pls be kind enough to provide me with a solution.
> 

Saminda

HttpMethod#abort() is probably what you want

Hope this helps

Oleg


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

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