此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。
206 Partial Content
HTTP206 Partial Content成功回應狀態碼是為了回應範圍請求而發送的。回應主體包含請求的Range 標頭中所指定的資料範圍。
回應的格式取決於請求的範圍數量。如果只請求了一個範圍,則整個回應的Content-Type 會設為文件的類型,並提供一個Content-Range。如果請求了多個範圍,則Content-Type 會設為multipart/byteranges,且每個片段都涵蓋一個範圍,並帶有其各自的Content-Range 和Content-Type 標頭來描述它。
In this article
狀態
http
206 Partial Content範例
>接收單一請求範圍的206 回應
以下是請求圖片檔案的單一範圍21010-(從 21010 位元組到檔案結尾)時的206 回應範例。回應包含image/gif 的Content-Type,並提供了Content-Range:
http
GET /z4d4kWk.gif HTTP/1.1Host: images.example.comRange: bytes=21010-http
HTTP/1.1 206 Partial ContentDate: Wed, 15 Nov 2015 06:25:24 GMTLast-Modified: Wed, 15 Nov 2015 04:58:08 GMTContent-Range: bytes 21010-47021/47022Content-Length: 26012Content-Type: image/gifETag: "abc123"Accept-Ranges: bytes# 26012 位元組的部分圖片資料…接收多個請求範圍的206 回應
以下是請求 PDF 檔案的兩個範圍時的206 回應範例。回應包含multipart/byteranges 的Content-Type,並為每個範圍提供獨立的Content-Type(application/pdf)和Content-Range。
http
GET /price-list.pdf HTTP/1.1Host: example.comRange: bytes=234-639,4590-7999http
HTTP/1.1 206 Partial ContentDate: Wed, 15 Nov 2015 06:25:24 GMTLast-Modified: Wed, 15 Nov 2015 04:58:08 GMTContent-Length: 1741Content-Type: multipart/byteranges; boundary=String_separatorETag: "abc123"Accept-Ranges: bytes--String_separatorContent-Type: application/pdfContent-Range: bytes 234-639/8000# 第一個範圍的內容(406 位元組)--String_separatorContent-Type: application/pdfContent-Range: bytes 4590-7999/8000# 第二個範圍的內容(3410 位元組)--String_separator--規範
| Specification |
|---|
| HTTP Semantics> # status.206> |