Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-2121

307 redirect failure with "Premature end of Content-Length delimited message body" when Content-Length given

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Not A Bug
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: HttpCache
    • Labels:
      None

      Description

      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

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

      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:
      GET https://ghcr.io/v2/github/super-linter/blobs/sha256:c7ac13e5f90fc4ec084e37323433806d2b693ec0954243b5fd1eac938db3c1b7
      Accept:
      Accept-Encoding: gzip
      Authorization: <Not Logged>
      
      
      • Sample response:
      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
      
      
      • Stack trace:
      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)
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              francium25 Chanseok Oh
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: