hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Enabling HTTP Pipelining
Date Thu, 18 Mar 2010 23:23:44 GMT
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


Mime
View raw message