Takeaways
- The
206 Partial Contentsuccess status response code indicates that the request has succeeded and the body contains the requested ranges of data, as described in theRangeheader of the request. - If there is only one range, the
Content-Typeof the whole response is set to the type of the document, and aContent-Rangeis provided. - If several ranges are sent back, the
Content-Typeis set tomultipart/byterangesand each fragment covers one range, withContent-RangeandContent-Typedescribing it.
Understanding partial content
- The server is successfully fulfilling a range 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
Rangeheader field. - If a single part is being transferred, the server generating the
206response must generate aContent-Rangeheader field, describing what range of the selected representation is enclosed, and a payload consisting of the range. 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 multiple parts are being transferred, the server generating the
206response must generate amultipart/byterangespayload, and aContent-Typeheader field containing themultipart/byterangesmedia type and its required boundary parameter. To avoid confusion with single-part responses, a server must not generate aContent-Rangeheader field in the HTTP header section of a multiple part response (this field will be sent in each part instead). - Within the header area of each body part in the multipart payload, the server must generate a
Content-Rangeheader field corresponding to the range being enclosed in that body part. If the selected representation would have had aContent-Typeheader field in a200 OKresponse, the server should generate that sameContent-Typefield in the header 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--Information
- When multiple ranges are requested, a server may coalesce any of the ranges that overlap, or that are separated by a gap that is smaller than the overhead of sending multiple parts, regardless of the order in which the corresponding byte-range-spec appeared in the received
Rangeheader field. - Since the typical overhead between parts of a
multipart/byterangespayload is around 80 bytes, depending on the selected representation's media type and the chosen boundary parameter length, it can be less efficient to transfer many small disjoint parts than it is to transfer the entire selected representation. - A server must not generate a multipart response to a request for a single range, since a client that does not request multiple parts might not support multipart responses. However, a server may generate a
multipart/byterangespayload with only a single body part if multiple ranges were requested and only one range was found to be satisfiable or only one range remained after coalescing. A client that cannot process amultipart/byterangesresponse must not generate a request that asks for multiple ranges. - When a multipart response payload is generated, the server should send the parts in the same order that the corresponding byte-range-spec appeared in the received
Rangeheader field, excluding those ranges that were deemed unsatisfiable or that were coalesced into other ranges. A client that receives a multipart response must inspect theContent-Rangeheader field present in each body part in order to determine which range is contained in that body part; a client cannot rely on receiving the same ranges that it requested, nor the same order that it requested. - When a
206response is generated, the server must generate the following header fields, in addition to those required above, if the field would have been sent in a200 OKresponse to the same request:Date,Cache-Control,ETag,Expires,Content-Location, andVary. - If a
206is generated in response to a request with anIf-Rangeheader field, the sender should not generate other representation header fields beyond those required above, because the client is understood to already have a prior response containing those header fields. Otherwise, the sender must generate all of the representation header fields that would have been sent in a200 OKresponse to the same request. - A
206response is cacheable by default; i.e., unless otherwise indicated by explicit cache controls.