Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Should fully consume the InputStream of InputStreamResponseListener before close it?


Cao,

The answer is "it depends".

Closing the stream will result in the connection being closed and not reused for other requests.  Making new connections can be expensive, especially if SSL is used, plus new connections are often slower than old connections as their flow control windows are not well sized.

So fully consuming some content so a connection may be reused may be cheaper than closing... but if generating the data is expensive or there is a lot of data yet  to come, then perhaps not.....

so your mileage may vary!







On Wed, 9 Oct 2019 at 01:56, Đạt Cao Mạnh <caomanhdat317@xxxxxxxxx> wrote:
Hi guys,

I kinda see this pattern frequently in Apache HttpClient
Please note that if response content is not fully consumed the underlying connection cannot be safely re-used and will be shut down and discarded by the connection manager. 

Wondering it will be the same pattern need to apply when uses InputStreamResponseListener? Based on Javadoc 
If the consumer is faster than the producer, then the consumer will block with the typical InputStream.read() semantic. If the consumer is slower than the producer, then the producer will block until the client consumes
So I kinda assume that close() without fully consume the InputStream will be better (since producer doesn't need to put more data into the stream). Is that true?

Thanks!
------
Cao Mạnh Đạt
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users


--

Back to the top