Content-Range
The Content-Range header indicates the which bytes are part of the response part, out of the entire selected representation. It is used in response to a Range request.
Writing responses (servers)
The Content-Range header is only meaningful in an 206 (Partial Content) response.
The Content-Range header is only used in the headers for the message body that is the partial content. For responses with a single range, it will be found in the HTTP message headers. For responses with multiple parts, it will be placed inside the multipart/byteranges
document, in the message headers for each part.
See the HTTP Range Requests specification for details.
Reading responses (clients)
The Content-Range header may appear either in the headers of a 206 (Partial Content) response, the entire response body is the partial response.
If the 206 response lacks a Content-Range header, then the body is a document that includes multiple ranges. When multiple ranges are returned, note that they may sometimes be out-of-order from the requested order. Clients must look at the Content-Range field of each part to determine what to do with that part.
Clients that issue a Range request must understand the Content-Range header; this includes caches that are forwarding requests from an upstream client. If caches do not want to implement partial response logic, they may simply not cache 206
responses from the server.
Overview table
- Name
- Content-Range
- Description
- Indicates the offset of the returned part from the entire representation.
- Direction
- Response
- Specification
- RFC 9110: HTTP Semantics §14.4. Content-Range
Syntax
Content-Range = byte-content-range / other-content-range
byte-content-range = bytes-unit SP ( byte-range-resp / unsatisfied-range )
byte-range-resp = byte-range "/" ( complete-length / "*" )
byte-range = first-byte-pos "-" last-byte-pos
unsatisfied-range = "*/" complete-length
complete-length = 1*DIGIT
other-content-range = other-range-unit SP other-range-resp
other-range-resp = *CHAR
Example
In this example, the complete length of the selected representation is 1234 bytes, but the response omits the first 42 bytes (i.e. bytes 0 through 41 inclusive).
Content-Range: bytes 42-1233/1234
In this response, the complete length of the selected representation is unknown:
Content-Range: bytes 42-1233/*
History
- 1999-06: RFC 2616 §14.16. Content-Range
- 2014-06: RFC 7233: Hypertext Transfer Protocol (HTTP/1.1): Range Requests §4.2. Content-Range
- 2022-06: RFC 9110 §14.4. Content-Range. This update describes use in requests.