17

I am not grasping the idea behind content-length and byte ranges as specified by HTTP 1.1 Is there are connection between the two of some sort? If a client requests in terms of byte ranges, say 0-100 out of 200, will the first response contain the "content-length" equal to 100 bytes followed by 100 actual data?

Thanks

1 Answers1

35

The Content-Length entity-header field indicates the size of the entity-body […] sent to the recipient […]

In a non-multipart message the entity-body is the body of the HTTP message as it only contains one entity. So the Content-Length value indicates the length of the message body that is sent and not the size of the whole resource.

So for a partial content response on a 0-100 byte range request (first byte and last byte inclusive) the Content-Length of the response will be 0 ≤ size ≤ 101.

In case of a 12345 byte long resource the response could look like this:

HTTP/1.1 206 Partial Content
Content-Range: bytes 0-100/12345
Content-Length: 101

… 101 bytes of content …
Gumbo
  • 643,351
  • 109
  • 780
  • 844
  • 1
    Thanks for clearing it out. Was pretty confusing, the HTTP response you wrote cleared it out nicely! –  Feb 19 '11 at 20:16
  • helped me solve my issue. android mediaplayer was giving an incorrect duration thanks a bunch. – frostymarvelous Nov 17 '14 at 14:26