HTTP Headers
Range
The HTTP Range
request header specifies which part of a resource the server should return.
Multiple sections can be requested simultaneously within a single Range
header, and the server may respond with these ranges in a multipart document.
If ranges are provided, the server responds with the 206 Partial Content
status code.
If the requested ranges are invalid, the server will return a 416 Range Not Satisfiable
error.
If a server does not support range requests, it might ignore the Range
header and send the complete resource with a 200
status code.
Historically, browsers used the header Accept-Ranges: none
to disable features like pause or resume in download managers.
However, since a server ignoring the Range
header is equivalent to responding with Accept-Ranges: none
, this header is now rarely used.
Currently, only bytes
units are registered.
These represent offsets (zero-indexed and inclusive).
If the content is encoded (such as compressed), each byte range refers to the encoded sequence, not the decoded data.
The header is considered a CORS-safelisted request header when it specifies a single byte range.
Header type | Request header |
Syntax
Syntax
The HTTP Range header allows clients to request specific parts of a resource. The syntax involves specifying a unit and a range. The following formats are available:
- Range: <unit>=<range-start>-
- Range: <unit>=<range-start>-<range-end>
- Range: <unit>=&;lt;range-start>-<range-end>, …, <range-startN>-<range-endN>
- Range: <unit>=-<suffix-length>
Directives
Directives
<unit>
The unit in which ranges are specified. Currently, only
bytes
is a recognized unit.<range-start>
An integer in the specified unit indicating the starting position of the requested range.
<range-end>
An integer in the specified unit indicating the ending position of the requested range. If this value is omitted, the range extends to the end of the resource.
<suffix-length>
An integer specifying the number of units from the end of the resource to include in the response.
Example
The following examples demonstrate how to make requests using the Range
header for CORS-safe and multiple range requests. Additional examples can be found in the guide on HTTP range requests.
The Range
header is used to request specific parts of a resource. For example, requesting the first 500 bytes of a resource can be done as follows:
Request:
Range: bytes=0-499
To request the second 500 bytes, use:
Request:
Range: bytes=500-999
If the end position is omitted, the request fetches all remaining units of the resource. For example, to request the last 100 bytes of a 1000-byte resource, send:
Request:
Range: bytes=900-
When the total size of the resource is unknown, the last n bytes can be retrieved using a suffix range:
Request:
Range: bytes=-100
For requesting multiple ranges simultaneously, such as bytes 200-999, 2000-2499, and from byte 9500 onward in a 10000-byte resource, the header should look like:
Request:
Range: bytes=200-999, 2000-2499, 9500-
This request asks for the first 800 bytes, a middle segment, and the last 500 bytes. Note that requests with overlapping ranges (e.g., 0-499, -500) might be rejected if the resource’s size doesn’t support it.
To check if a server supports range requests, you can make a HEAD request for an image:
Request:
curl -v –http1.1 -I https://i.imgur.com/z4d4kWk.jpg
The server should respond with a status code 200 and include the header Accept-Ranges: bytes if range requests are supported:
Response:
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 146515
Content-Type: image/jpeg
…
Accept-Ranges: bytes
How to Modify Header using Requestly
- Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
- Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
- Add a new header modification:
- Under “Action”, select “Add” or “Override”.
- In the “Header Name” field, enter Range.
- In the “Header Value” field, enter your desired byte range value (e.g., bytes=0-499).
- Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/*).
- Save the rule.
Once configured, Requestly will inject the specified Range header into matching requests, enabling you to simulate partial content retrieval and effectively test how your server handles byte-range requests.
Table of Contents
- No headings found.