You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Hemant Tiwari <he...@gmail.com> on 2010/11/03 17:31:50 UTC

How can I get access to underlying socket from HttpClient?

Hi,

I am using HttpClient for connecting to streaming server. At client side I
am checking for server response and in case I get an unexpected response I
am trying to close connection.

My question is

Is there any way for me to use or get access to socket to terminate my Http
streaming (received as chunk data) from server.

Right now I was not able to locate a way to close a connection as
inputstream.close() doesn't work. And streaming connection stays on till
server does not close.

Thanks,
Hemant

Re: How can I get access to underlying socket from HttpClient?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2010-11-03 at 12:31 -0400, Hemant Tiwari wrote:
> Hi,
> 
> I am using HttpClient for connecting to streaming server. At client side I
> am checking for server response and in case I get an unexpected response I
> am trying to close connection.
> 
> My question is
> 
> Is there any way for me to use or get access to socket to terminate my Http
> streaming (received as chunk data) from server.
> 

HttpClient makes intentionally difficult to have direct access to the
underlying HTTP connection. It is possible but strongly discouraged.

> Right now I was not able to locate a way to close a connection as
> inputstream.close() doesn't work. And streaming connection stays on till
> server does not close.
> 

Use HttpUriRequest#abort() method to shut down the underlying
connection.

hope this helps

Oleg



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