NRaf
NRaf

Reputation: 7549

What to return when range HTTP header requests last byte of file?

I need to handle the Range header programatically in Java for supporting media files on iOS.

If my file is 23843 bytes, for example, I'm getting a request with a range header:

Range: bytes 23842-23842

What am I meant to return in this case? Is it just the last byte of the file?

Upvotes: 0

Views: 509

Answers (1)

nmaier
nmaier

Reputation: 33162

You should send the file from offset 23842 to offset 23842, so yes, that comes out as one byte.

The spec actually gives a similar example:

  • The first and last bytes only (bytes 0 and 9999): bytes=0-0,-1

(The important bit here being that 0-0 = first byte)

Upvotes: 1

Related Questions