You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Sam Berlin <sb...@gmail.com> on 2008/06/04 20:54:56 UTC

Timing of HttpProcessor.process w/ ClientHandlers

Hi Folks,

I'm starting to get into using the client side of httpcore-nio, and am
using AsyncNHttpClientHandler w/ NHttpRequestExecutionHandler.

One thing I'm finding slightly odd is the order that way the handlers
& processors are notified of incoming responses.  The order right now
is:

  1) NHttpRequestExecutionHandler.responseEntity [if an entity exists]
  2) HttpProcessor.process [after entity consuming completes]
  3) NHttpRequestExecutionHandler.handleResponse

I'd like to shift the the HttpProcessor.process to be first, so that
headers in the response can be processed & analyzed before the entity
is fully consumed.  Currently, when HttpProcess.process is called on a
response, the entity exists within the response and can be gotten &
parsed.  This would change that, so the entity cannot be *read* in the
processor.  (It could still be analyzed for size, content-type, etc..)

This enables header interceptors to work on entities who fail to read
the entire message.  It also enables interceptors to work earlier on
messages that have very long bodies.  It does prevent interceptors
from looking at the contents of the entity, though.

If folks think this is OK, I'll whip up a patch.

Sam

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


Re: Timing of HttpProcessor.process w/ ClientHandlers

Posted by Oleg Kalnichevski <ol...@apache.org>.
Sam Berlin wrote:
> Hi Folks,
> 
> I'm starting to get into using the client side of httpcore-nio, and am
> using AsyncNHttpClientHandler w/ NHttpRequestExecutionHandler.
> 
> One thing I'm finding slightly odd is the order that way the handlers
> & processors are notified of incoming responses.  The order right now
> is:
> 
>   1) NHttpRequestExecutionHandler.responseEntity [if an entity exists]
>   2) HttpProcessor.process [after entity consuming completes]
>   3) NHttpRequestExecutionHandler.handleResponse
> 
> I'd like to shift the the HttpProcessor.process to be first, so that
> headers in the response can be processed & analyzed before the entity
> is fully consumed.  Currently, when HttpProcess.process is called on a
> response, the entity exists within the response and can be gotten &
> parsed.  This would change that, so the entity cannot be *read* in the
> processor.  (It could still be analyzed for size, content-type, etc..)
> 
> This enables header interceptors to work on entities who fail to read
> the entire message.  It also enables interceptors to work earlier on
> messages that have very long bodies.  It does prevent interceptors
> from looking at the contents of the entity, though.
> 
> If folks think this is OK, I'll whip up a patch.
> 

Sam,

Sounds reasonable. Protocol interceptors that are based on blocking I/O 
also run protocol interceptors on messages before their content is 
consumed. That would make NIO and BIO protocol handlers more consistent.

Cheers

Oleg


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


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