Prajwal Prajwal - 1 year ago 110
HTTP Question

HTTP range request for last byte

I'm a newbie and I've been studying range-request for byte serving. I found that server has to send byte-range from as this

Content-Range: bytes 734-1233/1234

for the last byte range. But how would browser get the last byte of the file when the request itself is till last but one byte?

link I've been referring :

Joe Joe
Answer Source

The current standard is RFC 7233. From 2.1 Byte Ranges:

The first-byte-pos value in a byte-range-spec gives the byte-offset
of the first byte in a range.  The last-byte-pos value gives the
byte-offset of the last byte in the range; that is, the byte
positions specified are inclusive.  Byte offsets start at zero.

Applying this to the the examples in 4.2 Content-Range:

The following are examples of Content-Range values in which the
selected representation contains a total of 1234 bytes:

o  The first 500 bytes:

     Content-Range: bytes 0-499/1234

Since the range is zero-based, 0 is the first byte and 499 is the 500th. So, 1233 is the final byte of a 1234-byte document.