You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Jens Wilke <jw...@headissue.com> on 2008/04/21 20:51:42 UTC

HttpPost, returned Entity is not consuming input on writeTo()

Hi all,

I am testing with http-client-4.0-alha3.

Roughly, I have this code:

		HttpPost p = new HttpPost(url...);
		p.setEntity(entity....);
		HttpResponse r = httpClient.execute(p);
		HttpEntity ent = r.getEntity();
		OutputStream out = ...
		ent.writeTo(out);
		// we need this seperate call, so the connection is released
		ent.consumeContent();
		out.close();

The extra consumeContent() call is needed so that the connection gets freed.
However, I would expect writeTo() is doing this, since it processes the whole input.

Bug or feature? ;)

Best,

Jens

-- 
"Everything superfluous is wrong!"

   // Jens Wilke - headissue GmbH - Munich - Germany
 \//  http://www.headissue.com

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


Re: HttpPost, returned Entity is not consuming input on writeTo()

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2008-04-21 at 20:51 +0200, Jens Wilke wrote:
> Hi all,
> 
> I am testing with http-client-4.0-alha3.
> 
> Roughly, I have this code:
> 
> 		HttpPost p = new HttpPost(url...);
> 		p.setEntity(entity....);
> 		HttpResponse r = httpClient.execute(p);
> 		HttpEntity ent = r.getEntity();
> 		OutputStream out = ...
> 		ent.writeTo(out);
> 		// we need this seperate call, so the connection is released
> 		ent.consumeContent();
> 		out.close();
> 
> The extra consumeContent() call is needed so that the connection gets freed.
>
> However, I would expect writeTo() is doing this, since it processes the whole input.
> 
> Bug or feature? ;)
> 

Hi Jens,

This sounds like a bug. Could you please retest your code against the
latest SVN snapshot and open a JIRA ticket if the problem can still be
reproduced?

Oleg 




> Best,
> 
> Jens
> 


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


Re: HttpPost, returned Entity is not consuming input on writeTo()

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2008-04-21 at 20:51 +0200, Jens Wilke wrote:
> Hi all,
> 
> I am testing with http-client-4.0-alha3.
> 
> Roughly, I have this code:
> 
> 		HttpPost p = new HttpPost(url...);
> 		p.setEntity(entity....);
> 		HttpResponse r = httpClient.execute(p);
> 		HttpEntity ent = r.getEntity();
> 		OutputStream out = ...
> 		ent.writeTo(out);
> 		// we need this seperate call, so the connection is released
> 		ent.consumeContent();
> 		out.close();
> 
> The extra consumeContent() call is needed so that the connection gets freed.
> However, I would expect writeTo() is doing this, since it processes the whole input.
> 
> Bug or feature? ;)
> 

Jens,

I fixed the problem on SVN trunk

Oleg

> Best,
> 
> Jens
> 


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