206 Partial Content
The HTTP 206 Partial Content status code indicates a request completed successfully and the message body contains the requested ranges of data. The 206 status code is heuristically cacheable.
Usage
The 206 Partial Content status code is returned in response to a request containing one or more Range headers. A Range header specifies which parts of the document the server returns, and the server optionally delivers the data as a multipart document.
When a single Range header is specified, the Content-Length header reflects the size of the transferred range (the payload body), the Content-Type header matches the document type, and a Content-Range header indicates which section is included. The full document size appears in the Content-Range header's complete-length field. The requested data follows in the message body.
For multiple ranges, the
Content-Length header indicates
the total bytes in the message body. The initial
Content-Type header is set to
multipart/byteranges and subsequent
Content-Type /
Content-Range pairs describe each
range. The server does not include a
Content-Range field in the initial
header.
In multi-range requests, the server optionally merges overlapping ranges or those separated by a gap smaller than the overhead of sending an additional part. This is done for efficiency, so receiving fewer parts than requested does not necessarily indicate an error. The inverse is not true: a server does not generate multiple parts when only a single range is requested.
Aside from the count of ranges, the order of parts is also not guaranteed. A server makes an effort to send ranges in the same order as requested, but this is not always practical.
Regardless of how many ranges were requested, the Content-Range header includes the total resource size. When the size is unknown at the time of response, an asterisk denotes the value.
When the server is unable to return the requested ranges, a 416 status code is returned. Some servers instead return a 200 with the entire document in the message body.
Example of single-range retrieval
The client requests a block of data inside a video file using the Range header. The server returns the requested range, indicating an MP4-encoded video.
Request
GET /videos/sample.mp4 HTTP/1.1
Host: www.example.re
Range: bytes=25000-75000
Response
HTTP/1.1 206 Partial Content
Content-Type: video/mp4
Content-Length: 50001
Content-Range: bytes 25000-75000/100000
<50,001 bytes of video data>
Alternate response when the total size is unknown
HTTP/1.1 206 Partial Content
Content-Type: video/mp4
Content-Length: 50001
Content-Range: bytes 25000-75000/*
<50,001 bytes of video data>
Example of multi-range retrieval
When more than one range is requested, the client specifies each range in the request. Ranges are placed on different lines or comma-delimited on the same line. The server uses a string separator to denote the boundary between range parts.
Request
GET /videos/sample.mp4 HTTP/1.1
Host: www.example.re
Range: bytes=100-250, 1500-2000, 5000-5200
Response
HTTP/1.1 206 Partial Content
Content-Length: 1115
Content-Type: multipart/byteranges; boundary=range_sep
--range_sep
Content-Type: video/mp4
Content-Range: bytes 100-250/75000
<151 bytes of video data as the first range>
--range_sep
Content-Type: video/mp4
Content-Range: bytes 1500-2000/75000
<501 bytes of video data as the second range>
--range_sep
Content-Type: video/mp4
Content-Range: bytes 5000-5200/75000
<201 bytes of video data as the third range>
--range_sep--
Code references
.NET
HttpStatusCode.PartialContent
Rust
http::StatusCode::PARTIAL_CONTENT
Rails
:partial_content
Go
http.StatusPartialContent
Symfony
Response::HTTP_PARTIAL_CONTENT
Python3.5+
http.HTTPStatus.PARTIAL_CONTENT
Java
java.net.HttpURLConnection.HTTP_PARTIAL
Apache HttpComponents Core
org.apache.hc.core5.http.HttpStatus.SC_PARTIAL_CONTENT
Angular
@angular/common/http/HttpStatusCode.PartialContent
Takeaway
The HTTP 206 Partial Content status code confirms one or more ranges of data were successfully processed. The data follows as one or more sections in the response message body.