You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by James Leigh <ja...@leighnet.ca> on 2010/03/18 21:33:00 UTC

Enabling HTTP Pipelining

Hi all,

I would like to handle pipelined requests concurrently. However,
AsyncNHttpServiceHandler doesn't call NHttpRequestHandler#handle until
the previous response is submitted. How can I handle requests on the
same TCP stream concurrently?

I also have trouble getting pipelining working on the client.
AsyncNHttpClientHandler#requestReady doesn't do anything if there is a
pending response on the connection (i.e. state is not
ClientConnState.READY). If this condition was removed it seems to
pipeline the requests asynchronously. Is there an equivalent
AsyncNHttpClientHandler that support this or a setting I have
overlooked?

Thanks,
James
            


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


Re: Enabling HTTP Pipelining

Posted by Oleg Kalnichevski <ol...@apache.org>.
James Leigh wrote:
> On Fri, 2010-03-19 at 00:23 +0100, Oleg Kalnichevski wrote:
>> On Thu, 2010-03-18 at 18:46 -0400, James Leigh wrote:
>>> On Thu, 2010-03-18 at 23:27 +0100, Oleg Kalnichevski wrote:
>>>> James
>>>>
>>>> Presently AsyncNHttpClientHandler does not support request pipelining, 
>>>> as it pretty much mutually exclusive with 'expect: continue' 
>>>> handshaking. You will have to develop a custom NHttpClientHandler 
>>>> implementation if you need support for request pipelining.
>>>>
>>>> Oleg
>>>>
>>> Okay understood, but I could imagine a client handler that would support
>>> both.
>> There is a very early prototype of an asynchronous HTTP client based on
>> HttpCore NIO and HttpClient in SVN:
>>
>> http://svn.apache.org/repos/asf/httpcomponents/asynchttpclient/trunk/   
>>
>> I was thinking about adding support for request pipelining to it, if I
>> ever get around to hacking on it again. 
>>
>>
> 
> 
> I am going to stick with AsyncNHttpClientHandler for this project. How
> does expect-continue work in AsyncNHttpClientHandler? Does it also use a
> blocking interface?
> 
> 

Client-side 'expect-continue' code is fully asynchronous, as it does not 
require a callback of any kind.


>>>  If I create a patch for AsyncNHttpClientHandler to switch between
>>> HTTP pipelining and 'expect: continue' modes based on the presence or
>>> absents of the expect header in the most recent request, would HttpCore
>>> team consider it?
>>>
>> Absolutely.
>>
>>> Also what about server side pipelining? Is there any way for
>>> AsyncNHttpServiceHandler to support pipelining? Any hints on what would
>>> need to change to support it?
>>>
>> It should not be that difficult, I believe. Essentially all it takes is
>> an additional queue for pipelined requests and a piece of control logic
>> that ensures the queue gets drained before a non-pipelineable request
>> such as POST is processed.
>>
>> I just never felt pipelining was that important to justify spending time
>> and efforts on it and risk getting beaten by my wife.
>>
>> Having said all that, I will happily review and apply a patch that adds
>> pipelining capabilities.
>>
> 
> I'll see about sending you a patch this summer.
> 

I am looking forward to that.

Cheers

Oleg

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


Re: Enabling HTTP Pipelining

Posted by James Leigh <ja...@leighnet.ca>.
On Fri, 2010-03-19 at 00:23 +0100, Oleg Kalnichevski wrote:
> On Thu, 2010-03-18 at 18:46 -0400, James Leigh wrote:
> > On Thu, 2010-03-18 at 23:27 +0100, Oleg Kalnichevski wrote:
> > > 
> > > James
> > > 
> > > Presently AsyncNHttpClientHandler does not support request pipelining, 
> > > as it pretty much mutually exclusive with 'expect: continue' 
> > > handshaking. You will have to develop a custom NHttpClientHandler 
> > > implementation if you need support for request pipelining.
> > > 
> > > Oleg
> > > 
> > 
> > Okay understood, but I could imagine a client handler that would support
> > both.
> 
> There is a very early prototype of an asynchronous HTTP client based on
> HttpCore NIO and HttpClient in SVN:
> 
> http://svn.apache.org/repos/asf/httpcomponents/asynchttpclient/trunk/   
> 
> I was thinking about adding support for request pipelining to it, if I
> ever get around to hacking on it again. 
> 
> 


I am going to stick with AsyncNHttpClientHandler for this project. How
does expect-continue work in AsyncNHttpClientHandler? Does it also use a
blocking interface?


> >  If I create a patch for AsyncNHttpClientHandler to switch between
> > HTTP pipelining and 'expect: continue' modes based on the presence or
> > absents of the expect header in the most recent request, would HttpCore
> > team consider it?
> > 
> 
> Absolutely.
> 
> > Also what about server side pipelining? Is there any way for
> > AsyncNHttpServiceHandler to support pipelining? Any hints on what would
> > need to change to support it?
> > 
> 
> It should not be that difficult, I believe. Essentially all it takes is
> an additional queue for pipelined requests and a piece of control logic
> that ensures the queue gets drained before a non-pipelineable request
> such as POST is processed.
> 
> I just never felt pipelining was that important to justify spending time
> and efforts on it and risk getting beaten by my wife.
> 
> Having said all that, I will happily review and apply a patch that adds
> pipelining capabilities.
> 

I'll see about sending you a patch this summer.

> > I notice that HttpExpectationVerifier is a blocking interface. Is there
> > an asynchronous alternative?
> > 
> 
> No, there is currently not. At the moment AsyncNHttpServiceHandler uses
> the same interface as the blocking protocol handler, which makes it
> unsuitable for non-trivial verification tasks such as credentials
> validation. Needs work.

This is what I suspected.

> > Thanks for such a good HTTP library!
> > 
> 
> I am glad you found HttpCore useful.
> 
> Cheers
> 
> Oleg
> 

Thanks,
James



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


Re: Enabling HTTP Pipelining

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2010-03-18 at 18:46 -0400, James Leigh wrote:
> On Thu, 2010-03-18 at 23:27 +0100, Oleg Kalnichevski wrote:
> > James Leigh wrote:
> > > Hi all,
> > > 
> > > I would like to handle pipelined requests concurrently. However,
> > > AsyncNHttpServiceHandler doesn't call NHttpRequestHandler#handle until
> > > the previous response is submitted. How can I handle requests on the
> > > same TCP stream concurrently?
> > > 
> > > I also have trouble getting pipelining working on the client.
> > > AsyncNHttpClientHandler#requestReady doesn't do anything if there is a
> > > pending response on the connection (i.e. state is not
> > > ClientConnState.READY). If this condition was removed it seems to
> > > pipeline the requests asynchronously. Is there an equivalent
> > > AsyncNHttpClientHandler that support this or a setting I have
> > > overlooked?
> > > 
> > > Thanks,
> > > James
> > >        
> > 
> > James
> > 
> > Presently AsyncNHttpClientHandler does not support request pipelining, 
> > as it pretty much mutually exclusive with 'expect: continue' 
> > handshaking. You will have to develop a custom NHttpClientHandler 
> > implementation if you need support for request pipelining.
> > 
> > Oleg
> > 
> 
> Okay understood, but I could imagine a client handler that would support
> both.

There is a very early prototype of an asynchronous HTTP client based on
HttpCore NIO and HttpClient in SVN:

http://svn.apache.org/repos/asf/httpcomponents/asynchttpclient/trunk/   

I was thinking about adding support for request pipelining to it, if I
ever get around to hacking on it again. 


>  If I create a patch for AsyncNHttpClientHandler to switch between
> HTTP pipelining and 'expect: continue' modes based on the presence or
> absents of the expect header in the most recent request, would HttpCore
> team consider it?
> 

Absolutely.

> Also what about server side pipelining? Is there any way for
> AsyncNHttpServiceHandler to support pipelining? Any hints on what would
> need to change to support it?
> 

It should not be that difficult, I believe. Essentially all it takes is
an additional queue for pipelined requests and a piece of control logic
that ensures the queue gets drained before a non-pipelineable request
such as POST is processed.

I just never felt pipelining was that important to justify spending time
and efforts on it and risk getting beaten by my wife.

Having said all that, I will happily review and apply a patch that adds
pipelining capabilities.

> I notice that HttpExpectationVerifier is a blocking interface. Is there
> an asynchronous alternative?
> 

No, there is currently not. At the moment AsyncNHttpServiceHandler uses
the same interface as the blocking protocol handler, which makes it
unsuitable for non-trivial verification tasks such as credentials
validation. Needs work.

> Thanks for such a good HTTP library!
> 

I am glad you found HttpCore useful.

Cheers

Oleg


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


Re: Enabling HTTP Pipelining

Posted by James Leigh <ja...@leighnet.ca>.
On Thu, 2010-03-18 at 23:27 +0100, Oleg Kalnichevski wrote:
> James Leigh wrote:
> > Hi all,
> > 
> > I would like to handle pipelined requests concurrently. However,
> > AsyncNHttpServiceHandler doesn't call NHttpRequestHandler#handle until
> > the previous response is submitted. How can I handle requests on the
> > same TCP stream concurrently?
> > 
> > I also have trouble getting pipelining working on the client.
> > AsyncNHttpClientHandler#requestReady doesn't do anything if there is a
> > pending response on the connection (i.e. state is not
> > ClientConnState.READY). If this condition was removed it seems to
> > pipeline the requests asynchronously. Is there an equivalent
> > AsyncNHttpClientHandler that support this or a setting I have
> > overlooked?
> > 
> > Thanks,
> > James
> >        
> 
> James
> 
> Presently AsyncNHttpClientHandler does not support request pipelining, 
> as it pretty much mutually exclusive with 'expect: continue' 
> handshaking. You will have to develop a custom NHttpClientHandler 
> implementation if you need support for request pipelining.
> 
> Oleg
> 

Okay understood, but I could imagine a client handler that would support
both. If I create a patch for AsyncNHttpClientHandler to switch between
HTTP pipelining and 'expect: continue' modes based on the presence or
absents of the expect header in the most recent request, would HttpCore
team consider it?

Also what about server side pipelining? Is there any way for
AsyncNHttpServiceHandler to support pipelining? Any hints on what would
need to change to support it?

I notice that HttpExpectationVerifier is a blocking interface. Is there
an asynchronous alternative?

Thanks for such a good HTTP library!

Cheers,
James


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


Re: Enabling HTTP Pipelining

Posted by Oleg Kalnichevski <ol...@apache.org>.
James Leigh wrote:
> Hi all,
> 
> I would like to handle pipelined requests concurrently. However,
> AsyncNHttpServiceHandler doesn't call NHttpRequestHandler#handle until
> the previous response is submitted. How can I handle requests on the
> same TCP stream concurrently?
> 
> I also have trouble getting pipelining working on the client.
> AsyncNHttpClientHandler#requestReady doesn't do anything if there is a
> pending response on the connection (i.e. state is not
> ClientConnState.READY). If this condition was removed it seems to
> pipeline the requests asynchronously. Is there an equivalent
> AsyncNHttpClientHandler that support this or a setting I have
> overlooked?
> 
> Thanks,
> James
>        

James

Presently AsyncNHttpClientHandler does not support request pipelining, 
as it pretty much mutually exclusive with 'expect: continue' 
handshaking. You will have to develop a custom NHttpClientHandler 
implementation if you need support for request pipelining.

Oleg

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