What Is a 206 Status Code?
The server is successfully fulfilling a scope request for the target resource by transferring one or more parts of the selected representation that correspond to the satisfiable ranges found in the request’s Range header field1.
If a single part is being transferred, the server rendering the 206 response MUST yield a Content-Range header field, explaining what range of the selected replica is enclosed, and a payload consisting of the scope. For example:
`HTTP/1.1 206 Partial Content
Date: Wed, 15 Nov 1995 06:25:24 GMT
Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT
Content-Range: bytes 21010-47021/47022
Content-Length: 26012
Content-Type: image/gif
… 26012 bytes of partial image data …`
If numerous parts are being transferred, the server causing the 206 response MUST yield a “multipart/byteranges” payload, and a Content-Type header field including the multipart/byteranges media type and its required limit parameter. To avoid disorder with single-part reactions, a server MUST NOT generate a Content-Range header field in the HTTP header section of a multiple-part comeback (this field will be sent in each part instead).
Within the header area of each body part in the multipart payload, the waitperson MUST generate a Content-Range header field approximating the scope being held in that body part. If the selected drawing would have had a Content-Type heading field in a 200 OK response, the server SHOULD yield that same Content-Type field in the heading area of each body part. For example:
`HTTP/1.1 206 Partial Content
Date: Wed, 15 Nov 1995 06:25:24 GMT
Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT
Content-Length: 1741
Content-Type: multipart/byteranges; boundary=THIS_STRING_SEPARATES
–THIS_STRING_SEPARATES
Content-Type: application/pdf
Content-Range: bytes 500-999/8000
…the first range…
–THIS_STRING_SEPARATES
Content-Type: application/pdf
Content-Range: bytes 7000-7999/8000
…the second range
–THIS_STRING_SEPARATES–`
When multiple ranges are ordered, a server MAY combine any of the ranges that coincide, or that are divided by a gap that is smaller than the overhead of sending numerous parts, regardless of the order in which the related byte-range-spec occurred in the acquired Range header field. Since the standard overhead between parts of a multipart/byteranges payload is around 80 bytes, relying on the selected representation’s media type and the chosen limitation parameter length, it can be less efficient to move many small disjoint parts than it is to reposition the entire selected replica.
A server MUST NOT yield a multipart comeback to a request for a single range, since a customer that does not order numerous parts might not support multipart responses. However, a server MAY generate a multipart/byteranges payload with only a single body part if multiple ranges were requested and only one field was found to be satisfiable or only one range stayed after connecting. A client that cannot process a multipart/byteranges comeback MUST NOT generate a proposal that asks for multiple fields.
When a multipart response payload is developed, the server SHOULD send the parts in the same order that the related byte-range-spec appeared in the accepted Range header field, excluding those ranges that were deemed unsatisfiable or that were coalesced into other fields. A client that acquires a multipart comeback MUST inspect the Content-Range header field gift in each body part to decide which scope is contained in that body part; a client cannot rely on obtaining the same ranges that it asked, nor the same order that it asked.
When a 206 response is developed, the server MUST generate the following header areas, in addition to those directed above, if the field would have been sent in a 200 OK response to the same request: Date, Cache-Control, ETag, Expires, Content-Location, and Vary.
If a 206 is generated in answer to a request with an If-Range header field, the sender SHOULD NOT render other illustration header fields beyond those required above, because the client is comprehended to already have a prior reply containing those header fields. Otherwise, the sender MUST render all of the representation header fields that would have been sent in a 200 OK reaction to the same request.
A 206 response is cacheable by default; i.e., unless otherwise distinguished by explicit cache controls.
- 1 Range RFC7233 Section 3.1
- 2 Internet Media Type multipart/byteranges RFC7233 Appendix A
- 3 Calculating Heuristic Freshness RFC7234 Section 4.2.2
- Source: RFC7233 Section 4.1
206 CODE REFERENCES
- Rails HTTP Status Symbol:partial_content
- Go HTTP Status Constant http.StatusPartialContent
- Symfony HTTP Status Constant Response::HTTP_PARTIAL_CONTENT
- Python2 HTTP Status Constant httplib.PARTIAL_CONTENT
- Python3+ HTTP Status Constant http.client.PARTIAL_CONTENT
- Python3.5+ HTTP Status Constant http.HTTPStatus.PARTIAL_CONTENT
How does a server respond with a 206 status code?
When a server sends a 206 status code, the client orders only part of the resource, and the server produces only that part. The server’s response includes the following:
- A 206 status code in the response header
- A “Content-Range” header, which determines the range of bytes returned in the response
- The requested scope of bytes in the response body
When is a 206 status code used?
A 206 status code gets used when the following are true:
- The client requests only the region of the resource
- The server can supply only that part
The server may respond with a 206 status code in the following scenarios:
- When a client asks for a large file and only needs a detailed portion of it
- When a client requests help with numerous parts, such as a video or audio file, and only orders part of it
- When a client creates a request with a Range header, asking for a specific part of a resource
Common reasons for a 206 status code
A 206 status code may occur for a few reasons, like:
- The client invites a distinct portion of a resource using the range header, causing the server to answer with a 206 status code
- The server sends a partial answer when the invited resource is too large to send at once
- The client or server experiences network latency, causing the server to send partial reactions to the client
What is the difference between a 206 status code and other HTTP status codes?
A 206 status code is distinct from other status codes because it’s a partial content response.
It indicates that the server is delivering only part of the requested resource, and the client invited only that specific part. Other status codes, such as 200 or 404, indicate the server is producing either the entire aid or that the resource cannot be found.
Help! How do I troubleshoot a 206 status code error?
If a client acquires a 206 status code error, try troubleshooting the issue by:
- Checking the network connection to ensure it’s durable and fast
- Ensuring the client’s range header is accurate and within the allowable range
- Contacting the server administrator to confirm the server is configured correctly
- Checking the server logs for any mistakes or issues that may have caused the 206 status code