Skip to content

Content-Range

Description

The Content-Range response header indicates where in a full body message a partial message belongs. It is sent with a partial response body to specify which part of the complete resource is being delivered in the response. This header is used in conjunction with the HTTP status code 206 Partial Content and is crucial for resumable downloads, range requests, and streaming media playback.

When a client requests a specific range of a resource using the Range request header, the server responds with a Content-Range header to precisely define which portion of the resource is being returned. This mechanism enables clients to request and receive only the parts of a resource they need, rather than the entire resource, which can significantly improve efficiency for large files.

Syntax

The syntax of the Content-Range header follows this structure:

Content-Range: <unit> <range-start>-<range-end>/<size>
  • <unit>: The unit in which ranges are specified. Almost always bytes.
  • <range-start>: The start position of the range (inclusive, 0-based).
  • <range-end>: The end position of the range (inclusive, 0-based).
  • <size>: The total size of the full resource, or * if unknown.

Example Syntax

Content-Range: bytes 200-1000/67589

This example indicates that the response contains bytes 200 through 1000 (inclusive) of a 67,589-byte resource.

Examples

Basic Range Request Example

A client requests a specific range of a file:

GET /example.mp4 HTTP/1.1
Host: example.com
Range: bytes=1024-2047

The server responds with the requested range:

HTTP/1.1 206 Partial Content
Date: Mon, 02 Jun 2025 21:00:00 GMT
Content-Type: video/mp4
Content-Length: 1024
Content-Range: bytes 1024-2047/10485760

[... 1024 bytes of data ...]

In this example, the server is returning bytes 1024 through 2047 of a 10,485,760-byte video file.

Multiple Ranges Example

A client requests multiple ranges of a document:

GET /document.pdf HTTP/1.1
Host: example.com
Range: bytes=0-499, 1000-1499, 5000-5499

The server responds with a multipart message containing the requested ranges:

HTTP/1.1 206 Partial Content
Date: Mon, 02 Jun 2025 21:10:30 GMT
Content-Type: multipart/byteranges; boundary=3d6b6a416f9b5
Content-Length: 1823

--3d6b6a416f9b5
Content-Type: application/pdf
Content-Range: bytes 0-499/8234

[... first 500 bytes of the PDF ...]
--3d6b6a416f9b5
Content-Type: application/pdf
Content-Range: bytes 1000-1499/8234

[... bytes 1000-1499 of the PDF ...]
--3d6b6a416f9b5
Content-Type: application/pdf
Content-Range: bytes 5000-5499/8234

[... bytes 5000-5499 of the PDF ...]
--3d6b6a416f9b5--

Resumable Download Example

A client attempts to resume a previously interrupted download:

GET /large-file.zip HTTP/1.1
Host: example.com
Range: bytes=5242880-

The server responds with the remainder of the file:

HTTP/1.1 206 Partial Content
Date: Mon, 02 Jun 2025 21:20:45 GMT
Content-Type: application/zip
Content-Length: 15728640
Content-Range: bytes 5242880-20971519/20971520

[... remaining bytes of the file ...]

In this example, the client is resuming a download starting from byte 5,242,880 of a 20,971,520-byte file.

Summary

The Content-Range response header is essential for efficient handling of large resources by enabling partial content delivery. By precisely defining which portion of a resource is being delivered, this header facilitates range requests, resumable downloads, and streaming media scenarios. When used in combination with the Range request header and the 206 Partial Content status code, it creates a powerful mechanism for clients to request and receive only the specific parts of a resource they need, improving bandwidth utilization and enabling advanced functionality like media streaming and resumable transfers.