On Fri, 2018-11-16 at 13:18 +0100, Joan Balagueró wrote:
> Hello,
> 
>  
> 
> I hope the last questions:
> 
>  
> 
> 1.       The validateAfterInactivity with a value of zero means no
> validation?
> 

Correct.

>  
> 
> 2.       Regarding the consume method, this is our implementation
> now:
> 
>  
> 
> @Override
> 
> public int consume(ByteBuffer src) throws IOException
> 
> {
> 
>   while (src.hasRemaining()) {
> 
>          byte[] dst = new byte[src.remaining()];
> 
>          src.get(dst, 0, src.remaining());
> 
>          this.vbaos.write(dst);
> 
>   }
> 
>  
> 
>   return ????;
> 

Given that your consumer simply writes data out into a unlimited buffer
of a sort it is safe to return Integer.MAX_VALUE here. In the next
release this method will no longer require a return value. 


> }
> 
>  
> 
> Triggered to pass incoming data to the data consumer. The consumer
> must
> consume the entire content of the data buffer.
> 
> è Is this the right (and optimal) way to consume the data buffer?
> 

If you expect all message bodies to be reasonably small it is probably
good enough, but for large messages you might want to avoid the entire
message in memory by using limited capacity and making the consumer
manage its capacity updates.

>  
> 
> The consumer must stop incrementing its capacity on the capacity
> channel and
> must return zero capacity from this method if it is unable to accept
> more
> data. Once the data consumer has handled accumulated data or
> allocated more
> intermediate storage it can update its capacity information on the
> capacity
> channel.
> 
> è Here I must admit I don’t understand this sentence at all. After
> googling
> a lot and reviewing your samples, I couldn’t find an example of
> consume
> method working with byte buffers (just with CharBuffer in the
> ‘AsyncClientHttpExchangeStreaming.java’, but in this case no value is
> returned in ‘data’ function). 
> 

Have a look at the AbstractClassicEntityConsumer for an example of a
more complex data consumer

https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/classic/AbstractClassicEntityConsumer.java



>          protected void data(final CharBuffer data, final boolean
> endOfStream) throws IOException {
> 
> while (data.hasRemaining()) {
> 
>  System.out.print(data.get());
> 
> }
> 
> if (endOfStream) {
> 
>  System.out.println();
> 
> }
> 
> }
> 
>  
> 
> What is the suggested value to return in this function?
> 

I am not sure I understand what function you mean here.

Oleg



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

Reply via email to