Chanseok Oh created HTTPCLIENT-2121:
---------------------------------------

             Summary: 307 redirect failure with "Premature end of 
Content-Length delimited message body" when Content-Length given
                 Key: HTTPCLIENT-2121
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2121
             Project: HttpComponents HttpClient
          Issue Type: Bug
          Components: HttpCache
            Reporter: Chanseok Oh


GitHub Container Registry (a Docker registry server) returns "307 Temporary 
Redirect" with "Content-Length:" set to a non-zero value but with no body. It 
then fails with

{code:java}
Caused by: org.apache.http.ConnectionClosedException: Premature end of 
Content-Length delimited message body (expected: 31,167; received: 0)
{code}

At least, the Apache Client could redirect without failing when a response body 
is empty for 3xx redirects even if "Content-Length:" is set.

* Sample request:

{code:java}
GET 
https://ghcr.io/v2/github/super-linter/blobs/sha256:c7ac13e5f90fc4ec084e37323433806d2b693ec0954243b5fd1eac938db3c1b7
Accept:
Accept-Encoding: gzip
Authorization: <Not Logged>

{code}

* Sample response:

{code:java}
HTTP/1.1 307 Temporary Redirect
Content-Length: 31167
Content-Type: application/octet-stream
Docker-Content-Digest: 
sha256:c7ac13e5f90fc4ec084e37323433806d2b693ec0954243b5fd1eac938db3c1b7
Docker-Distribution-Api-Version: registry/2.0
Etag: "sha256:c7ac13e5f90fc4ec084e37323433806d2b693ec0954243b5fd1eac938db3c1b7"
Location: 
https://github-production-container-registry.s3.amazonaws.com/blobs/sha256%3Ac7ac13e5f90fc4ec084e37323433806d2b693ec0954243b5fd1eac938db3c1b7?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAYXOCC6LC2SUN5FPM%2F20201019%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201019T143034Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&X-Amz-Signature=b4603c19d939e65e7eb93294ad854095dbe5173daffd2f3344db2eae30ece915
Date: Mon, 19 Oct 2020 14:30:34 GMT
X-GitHub-Request-Id: CDB2:4010:722EA:118BF2:5F8DA309

{code}

* Stack trace:

{code:java}
Caused by: org.apache.http.ConnectionClosedException: Premature end of 
Content-Length delimited message body (expected: 31,167; received: 0)
    at org.apache.http.impl.io.ContentLengthInputStream.read 
(ContentLengthInputStream.java:178)
    at org.apache.http.impl.io.ContentLengthInputStream.read 
(ContentLengthInputStream.java:198)
    at org.apache.http.impl.io.ContentLengthInputStream.close 
(ContentLengthInputStream.java:101)
    at org.apache.http.impl.execchain.ResponseEntityProxy.streamClosed 
(ResponseEntityProxy.java:142)
    at org.apache.http.conn.EofSensorInputStream.checkClose 
(EofSensorInputStream.java:228)
    at org.apache.http.conn.EofSensorInputStream.close 
(EofSensorInputStream.java:172)
    at java.io.FilterInputStream.close (FilterInputStream.java:181)
    at com.google.api.client.util.LoggingInputStream.close 
(LoggingInputStream.java:67)
    at com.google.api.client.http.HttpResponse.ignore (HttpResponse.java:417)
    at com.google.api.client.http.HttpRequest.execute (HttpRequest.java:1083)
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to