🎉 Requestly joins BrowserStack to build the future of application testing. Read more

HTTP Headers

Content Range

HTTP Header

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.

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:

Content-Range: <unit> <range>/<size>
Content-Range: <unit> <range>/*
Content-Range: <unit> */<size>

Directives

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.

Example

Partial content response

This <strong><code>206 Partial Content</code></strong> 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
HTTP/2 206<br>content-type: image/jpeg<br>content-length: 1024<br>content-range: bytes 0-1023/146515<br>…<br><br>(binary content)</code>

Range not satisfiable

If the server cannot fulfill the requested byte range, it should respond with a <code>416 Range Not Satisfiable</code> status, and the <Content-Range> header should indicate an asterisk (*) for the range, followed by the total size of the resource.

http
HTTP/2 416<br><br>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:

  1. Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
  2. Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
  3. 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).
  4. Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/videos/*).
  5. 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.