0

Just wanted to know if the GET Bucket op response ever skips the Content-Length header. I tested this and i saw that there was no Content-Length header in the response for GET Bucket op.

How does an application reading the response understand where the body of the response ends if the response doesn't contain Content-Length header?

Request-Response Snippet:

    GET /?max-keys=1000&prefix&delimiter=%2F HTTP/1.1
    Date: Sat, 09 Apr 2016 18:27:23 GMT
    x-amz-request-payer: requester
    Authorization: AWS AKIAIP3KAUILC4GG7A2A:UG3bGvIjayrxrkxEX1mfrvETy/M=
    Connection: Keep-Alive
    User-Agent: Cyberduck/4.9.19632 (Mac OS X/10.10.5) (x86_64)

    HTTP/1.1 200 OK
    x-amz-id-2: yg76HSq5j0mi0oR6dXF8ZfGq722kHBWiMQmNvXPqiLxr1S4nGj5GVn1RVrPQrOUfNynxxaMSYEY=
    x-amz-request-id: B4468E68E10B6AEF
    Date: Sat, 09 Apr 2016 18:27:25 GMT
    x-amz-bucket-region: us-east-1
    Content-Type: application/xml
    Server: AmazonS3
    Connection: close

    <?xml version="1.0" encoding="UTF-8"?>
    <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">......</ListBucketResult>

Thanks!

Rakshith
  • 31
  • 5

1 Answers1

0

The Content-Length header is optional in response. And it may not reflect the real content-length even if it presents. Think about gzipped response. So to answer the question: When no Content-Length is received, the client keeps reading until the server closes the connection.

In Java, keep calling InputStream.read() until it returns -1.

Is the Content-Length header required for a HTTP/1.0 response?

Community
  • 1
  • 1
Yangfan
  • 1,866
  • 1
  • 11
  • 13
  • Thanks for the reply Yangfan. However, if the client keeps reading until the connection gets closed, how will it be able to distinguish between the body for the current request being handled and the header of the next request? Also, AWS mandates the use of HTTP/1.1 i believe. – Rakshith Apr 11 '16 at 06:03
  • I was referring to Pipelining of GET commands on the same connection above. Just wanted to clarify that point here. – Rakshith Apr 11 '16 at 07:12