Range
Request header Ranges

Overview

Range requests only a portion of a resource (usually a byte range) rather than the whole thing. It is essential for resuming large downloads, seeking in media streams, and parallel segmented downloads.

Details

`Range: bytes=0-1023` requests the first 1024 bytes. If supported, the server returns 206 Partial Content with only that range plus `Content-Range: bytes 0-1023/146515` stating which part of the total and the full size. A server advertises range support via `Accept-Ranges: bytes` in responses. If it ignores the range, it simply sends the whole thing as 200 OK.

`bytes=1000-` means from byte 1000 to the end, and `bytes=-500` means the last 500 bytes. If the requested range exceeds the resource size, the server returns 416 Range Not Satisfiable, reporting the actual total via `Content-Range: bytes */146515`.

When resuming a download, if the resource changes mid-transfer the data could get scrambled, so it is safer to send `If-Range` (an ETag or date) so you get a partial response only if the resource is unchanged, and the full 200 if it changed.

Syntax

Range: <unit>=<start>-<end>[, <start>-<end>]*

e.g. Range: bytes=0-1023

Directives / values

bytes=<start>-<end>Request the inclusive byte range; e.g. 0-1023 is the first 1KB.
bytes=<start>-From start to the end (used for resuming downloads).
bytes=-<suffix>Request the last N bytes; e.g. -500 is the final 500 bytes.

Notes

Related headers

Related status codes

Specification