206 部分內容
HTTP 的206 部分內容 成功響應 狀態程式碼是在響應 範圍請求 時傳送的。響應主體包含請求資料範圍內的資料,這些資料在請求的 Range 標頭中指定。
響應的格式取決於請求的範圍數量。如果請求單個範圍,則整個響應的 Content-Type 設定為文件的型別,並提供 Content-Range。如果請求多個範圍,則 Content-Type 設定為 multipart/byteranges,每個片段覆蓋一個範圍,並具有自己的 Content-Range 和 Content-Type 標頭來描述它。
狀態
http
206 Partial Content
示例
接收單個請求範圍的 206 響應
以下是當請求影像檔案的單個範圍 21010-(從第 21010 個位元組到檔案末尾)時,206 響應的示例。響應包含 Content-Type 為 image/gif,並提供 Content-Range
http
GET /z4d4kWk.gif HTTP/1.1
Host: images.example.com
Range: bytes=21010-
http
HTTP/1.1 206 Partial Content
Date: Wed, 15 Nov 2015 06:25:24 GMT
Last-Modified: Wed, 15 Nov 2015 04:58:08 GMT
Content-Range: bytes 21010-47021/47022
Content-Length: 26012
Content-Type: image/gif
ETag: "abc123"
Accept-Ranges: bytes
# 26012 bytes of partial image data…
接收多個請求範圍的 206 響應
以下是當請求 PDF 檔案的兩個範圍時,206 響應的示例。響應包含 multipart/byteranges Content-Type,每個範圍都有一個單獨的 Content-Type(application/pdf)和 Content-Range。
http
GET /pricelist.pdf HTTP/1.1
Host: example.com
Range: bytes=234-639,4590-7999
http
HTTP/1.1 206 Partial Content
Date: Wed, 15 Nov 2015 06:25:24 GMT
Last-Modified: Wed, 15 Nov 2015 04:58:08 GMT
Content-Length: 1741
Content-Type: multipart/byteranges; boundary=String_separator
ETag: "abc123"
Accept-Ranges: bytes
--String_separator
Content-Type: application/pdf
Content-Range: bytes 234-639/8000
# content of first range (406 bytes)
--String_separator
Content-Type: application/pdf
Content-Range: bytes 4590-7999/8000
# content of second range (3410 bytes)
--String_separator--
規範
| 規範 |
|---|
| HTTP 語義 # status.206 |