You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Kenan Esau <ke...@privatesecuredata.com> on 2018/05/02 08:59:28 UTC

Generating Chunked Response

Hello,

I am trying to generate a chunked response. I tried different ways - but all have the same problem. The result is only sent to the client after the underlying stream is closed (or the encoder if I use HttpAsyncResponseProducer).

My suspicion is that this is related to the some buffers „in between“. Is there a possibility to flush my chunks? Can you point me to an example?

Regards

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


Re: Generating Chunked Response

Posted by Kenan Esau <ke...@privatesecuredata.com>.
Am 03.05.2018 um 10:03 schrieb Oleg Kalnichevski <ol...@apache.org>:
> 
> On Wed, 2018-05-02 at 10:59 +0200, Kenan Esau wrote:
>> Hello,
>> 
>> I am trying to generate a chunked response. I tried different ways -
>> but all have the same problem. The result is only sent to the client
>> after the underlying stream is closed (or the encoder if I use
>> HttpAsyncResponseProducer).
>> 
>> My suspicion is that this is related to the some buffers „in
>> between“. Is there a possibility to flush my chunks? Can you point me
>> to an example?
>> 
> 
> Hi Kenan
> 
> 
> The chunk transfer encoder used by HttpCore NIO does not immediately
> write out small data chunks to the underlying channel if they are below
> so called 'fragment size hint' value: 
> 
> https://github.com/apache/httpcomponents-core/blob/4.4.x/httpcore-nio/s
> rc/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java#L127
> 
> There is no means of flushing session output buffer from a
> HttpAsyncResponseProducer implementation but one can set 'fragment size
> hint' value to zero in order to force all chunk data to get committed
> to the channel immediately (at the expense of IP packet fragmentation).
> 
> https://github.com/apache/httpcomponents-core/blob/4.4.x/httpcore/src/m
> ain/java/org/apache/http/config/ConnectionConfig.java#L146
> 
> Hope this helps

Yep — thank you! That worked!

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


Re: Generating Chunked Response

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2018-05-02 at 10:59 +0200, Kenan Esau wrote:
> Hello,
> 
> I am trying to generate a chunked response. I tried different ways -
> but all have the same problem. The result is only sent to the client
> after the underlying stream is closed (or the encoder if I use
> HttpAsyncResponseProducer).
> 
> My suspicion is that this is related to the some buffers „in
> between“. Is there a possibility to flush my chunks? Can you point me
> to an example?
> 

Hi Kenan


The chunk transfer encoder used by HttpCore NIO does not immediately
write out small data chunks to the underlying channel if they are below
so called 'fragment size hint' value: 

https://github.com/apache/httpcomponents-core/blob/4.4.x/httpcore-nio/s
rc/main/java/org/apache/http/impl/nio/codecs/ChunkEncoder.java#L127

There is no means of flushing session output buffer from a
HttpAsyncResponseProducer implementation but one can set 'fragment size
hint' value to zero in order to force all chunk data to get committed
to the channel immediately (at the expense of IP packet fragmentation).

https://github.com/apache/httpcomponents-core/blob/4.4.x/httpcore/src/m
ain/java/org/apache/http/config/ConnectionConfig.java#L146

Hope this helps

Oleg


> Regards
> 
>     Kenan
> ---------------------------------------------------------------------
> 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