jira-importer opened a new issue, #1465:
URL: https://github.com/apache/httpcomponents-core/issues/1465

   **[Daniel 
Rabe](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=drabe)** 
opened 
**[HTTPCORE-257](https://issues.apache.org/jira/browse/HTTPCORE-257?redirect=false)**
 and commented
   
   While debugging a separate issue, I noticed that 
DefaultConnectionReuseStrategy is very sensitive to whether the server returns 
a positive content-length or content-length=-1 with chunked encoding. In 
particular, I saw two cases:
   (1) Server returns gzip response with Content-Length=-1, chunked encoding. 
The connection is reused.
   (2) Server returns gzip response with 
Content-Length=\<actual-number-of-bytes-in-response> The connection is NOT 
reused.
   
   This is because of the following code in DefaultConnectionReuseStrategy:
   
       if (entity.getContentLength() < 0) {
            if (!entity.isChunked() ||
                ver.lessEquals(HttpVersion.HTTP_1_0)) {
                // if the content length is not known and is not chunk
                // encoded, the connection cannot be reused
                return false;
            }
        }
   
   GzipDecompressingEntity implements its getContentLength as always returning 
-1. However, it is not chunked. Therefore, the connection is not reused.
   
   I'm not sure if you would consider this a bug or a request for enhancement, 
but it seems to me that if the server is returning an accurate content-length, 
the client should be able to consume that number of bytes, then reuse the 
connection.
   
   
   ---
   
   **Affects:** 4.1.1
   
   **Backported to:** 
[4.1.4](https://github.com/apache/httpcomponents-core/milestone/19?closed=1)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to