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 Helbrass <he...@gmail.com> on 2012/07/19 11:44:21 UTC

Wrong "Connection" header behaviour

Good day!

Just discovered really strange behaviour from HttpCore NIO 4.2.1, not sure  
if it's a bug or I'm just using it in a wrong way...

Steps to reproduce:

1. use NoConnectionReuseStrategy
2. add ResponseConnControl to HttpProcessors
3. implement almost empty HttpAsyncResponseProducer
4. make a request using Chromium
5. ResponseConnControl line 86 will not find entity and will set  
Connection header to keep-alive on line 100.
6. HttpAsyncService on line 552 will check ConnectionReuseStrategy and  
will close connection.

So as a result we have Connection: keep-alive reported but connection  
closed.
Workaround is of course to set own Connection header and do not add  
ResponseConnControl processor, but resulting code is quite messy...

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/

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


Re: Wrong "Connection" header behaviour

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2012-07-19 at 12:44 +0300, Helbrass wrote:
> Good day!
> 
> Just discovered really strange behaviour from HttpCore NIO 4.2.1, not sure  
> if it's a bug or I'm just using it in a wrong way...
> 
> Steps to reproduce:
> 
> 1. use NoConnectionReuseStrategy
> 2. add ResponseConnControl to HttpProcessors
> 3. implement almost empty HttpAsyncResponseProducer
> 4. make a request using Chromium
> 5. ResponseConnControl line 86 will not find entity and will set  
> Connection header to keep-alive on line 100.
> 6. HttpAsyncService on line 552 will check ConnectionReuseStrategy and  
> will close connection.
> 
> So as a result we have Connection: keep-alive reported but connection  
> closed.
> Workaround is of course to set own Connection header and do not add  
> ResponseConnControl processor, but resulting code is quite messy...
> 

I believe your expectations are slightly off. Usually
ConnectionReuseStrategy implementations is expected to make a decision
whether or not the connection can be re-used based on the properties of
the response message passed as a parameter. NoConnectionReuseStrategy,
however, indiscriminately returns false in all cases regardless of
message composition, hence the problem you are facing. 

You should either manually add 'connection: close' header if connection
is not to be re-used and continue using DefaultConnectionReuseStrategy
or replace ResponseConnControl with a custom interceptor that always
adds 'connection: close' header.

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