hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Implementing a simple non-blocking echo server
Date Tue, 16 Sep 2014 14:11:44 GMT
On Tue, 2014-09-16 at 13:49 +0100, Daniel Feist wrote:
> Hi,
> Jetty uses a default output buffer of 64KB, although the echo
> implementation I referenced works beyond this buffer size too.  When the
> internal buffer is full it writes to response channel, only closing (and
> flushing?) the channel once the request has been fully read and processed
> and response written.
> Forgetting Jetty now, playing around more with HttpCore I see this
> behaviour when debugging my implementation.  Is this right?
> - When the buffer size is smaller that the request body I'm using IoCtrl to
> suspend input and request output.
> - Because the ContentDecoder is not completed AsyncHttpHandler#handle is
> never called and my HttpAsyncResponseProducer never submitted (using
>  httpexchange.submitResponse).
> - As such, when org.apache.http.nio.protocol.HttpAsyncService#responseReady
> is called there is no HttpAsyncResponseProducer available.
> - Because there is not HttpAsyncResponseProducer available, the buffer is
> never read and IoCtrl.requestInput is never called to continue reading the
> body.
> I know what i'm trying to implement to learn httpcore may seem kind of
> artificial, but i'm struggling to make sense of this behaviour in the
> implementation.  Or is it simply that this is deliberate because handling
> the request and processing the response makes no sense at all until the
> request body has been fully read?  

Yes, it is deliberate and is based on a conscious design decision.
Nothing, however, stops you from tweaking HttpAsyncService to support
out of sync responses at the expense of compatibility with blocking HTTP

> Ignoring what i've been playing with, what is the best, most efficient way,
> of implementing a AsyncEchoHandler with httpcore?

I would probably opt to just truncate request content after a certain

However if your main goal is learning rather than some practical
application I would recommend taking your chances with building a custom
protocol handler using HttpAsyncService as your starting point.

Hope this helps


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

View raw message