Content Range
The HTTP Content-Range response header is used in range requests to specify the position of the response body content within a complete resource. It helps clients understand which part of the resource they have received, especially when downloading partial content.
Typically, this header appears only in responses with status 206 Partial Content or 416 Range Not Satisfiable.
Note: The Content-Range header is essential for byte-range requests, allowing efficient data transfer by requesting specific portions of a resource.
Syntax
In HTTP, the Content-Range header allows a client to specify the part of the resource being transferred. The syntax for this header is as follows:
Note: The placeholders <unit>, <range>, and <size> are to be replaced with actual values when using the header.
Content-Range: <unit> <range>/<size>
Content-Range: <unit> <range>/*
Content-Range: <unit> */<size>
Directives
<unit>
The unit used to specify ranges in requests. Currently, only bytes is supported for defining ranges.
<range>
A range is defined with the format <range-start>-<range-end>, where <range-start> and <range-end> are integers indicating the start and end positions of the range in the specified <unit>. Positions are zero-indexed and inclusive. The asterisk (*) is used in responses with 416 Range Not Satisfiable status to denote that the requested value is not a range.
<size>
The total size of the document, or * if the size is unknown.
Examples
Partial content response
This 206 Partial Content response indicates a partial reply, with the Content-Range header specifying that it contains the first 1024 bytes of a file that is 146,515 bytes long.
HTTP/2 206
content-type: image/jpeg
content-length: 1024
content-range: bytes 0-1023/146515
…
(binary content)
Range not satisfiable
If the server cannot fulfill the requested byte range, it should respond with a 416 Range Not Satisfiable status, and the Content-Range header should indicate an asterisk (*) for the range, followed by the total size of the resource.
HTTP/2 416
Content-Range: bytes */67589
How to Modify Header using Requestly
Requestly is a powerful Chrome extension that allows you to modify HTTP headers, including the Content-Range header. This is particularly useful when you want to test how your server handles partial content delivery or resume interrupted downloads. Steps to Modify the Content-Range Header:
- 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 Content-Range.
- In the “Header Value” field, enter your desired range value (e.g., bytes 0-499/1234).
- Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/videos/\*).
- Save the rule.
Once set up, Requestly will inject the Content-Range header into all matching requests, enabling you to simulate partial content requests or test how your server deals with ranged downloads.
Set headers visually: intercept and modify HTTP headers without touching your code using Requestly.
Download Free →