206 Partial Content
Description
The 206 Partial Content
status code indicates that the server is successfully fulfilling a partial GET request for a resource. This status code is used when the client has requested only a portion of a resource by using the Range
header field.
This status code is particularly useful for large resources such as videos, audio files, or large documents, where downloading the entire resource at once might be inefficient or unnecessary. It enables features like:
- Resume interrupted downloads
- Stream media content
- Implement parallel downloading
- Fetch specific sections of large documents
The server must include either a Content-Range header indicating the range being returned or a multipart/byteranges Content-Type if multiple ranges were requested.
Syntax
The server responds with a 206 Partial Content
status and includes information about the range being returned:
HTTP/1.1 206 Partial Content
Content-Range: bytes 21010-47021/47022
Content-Length: 26012
Content-Type: image/jpeg
[Partial content bytes]
For multiple ranges, a multipart response is used:
HTTP/1.1 206 Partial Content
Content-Type: multipart/byteranges; boundary=3d6b6a416f9b5
Content-Length: 385
--3d6b6a416f9b5
Content-Type: text/html
Content-Range: bytes 500-999/1234
[Bytes 500-999 of the resource]
--3d6b6a416f9b5
Content-Type: text/html
Content-Range: bytes 1200-1234/1234
[Bytes 1200-1234 of the resource]
--3d6b6a416f9b5--
Examples
Video Streaming Example
A client requests a specific segment of a video file:
Client Request:
Server Response:
HTTP/1.1 206 Partial Content
Content-Type: video/mp4
Content-Length: 1048576
Content-Range: bytes 1048576-2097151/8388608
Accept-Ranges: bytes
[1MB of video data]
Resume Download Example
A client resumes a previously interrupted download:
Client Request:
Server Response:
HTTP/1.1 206 Partial Content
Content-Type: application/pdf
Content-Length: 3145728
Content-Range: bytes 5242880-8388607/8388608
Accept-Ranges: bytes
[Remaining 3MB of the PDF file]
Multiple Range Request Example
A client requests multiple specific sections of an HTML document:
Client Request:
GET /articles/http-status-codes.html HTTP/1.1
Host: docs.example.com
Range: bytes=0-999, 2000-2999, 5000-5999
Server Response:
HTTP/1.1 206 Partial Content
Content-Type: multipart/byteranges; boundary=separation-string
Content-Length: 3438
--separation-string
Content-Type: text/html
Content-Range: bytes 0-999/10000
[First 1000 bytes of the HTML document]
--separation-string
Content-Type: text/html
Content-Range: bytes 2000-2999/10000
[Bytes 2000-2999 of the HTML document]
--separation-string
Content-Type: text/html
Content-Range: bytes 5000-5999/10000
[Bytes 5000-5999 of the HTML document]
--separation-string--
Summary
The 206 Partial Content
status code is a critical component of efficient content delivery on the web. It enables bandwidth optimization by allowing clients to request only the portions of a resource they need. This is particularly valuable for media streaming, resumable downloads, and efficient handling of large files. By supporting range requests, servers can provide better user experiences, especially in scenarios with limited bandwidth or when accessing specific sections of large resources.