206 Partial Content
The 206 Partial Content HTTP response status code is sent by the server to indicate that a specific range of data from the HTTP request has been successfully retrieved.
The 206 Partial Content HTTP response status code is sent by the server to signal that a specific range of data from the HTTP request has been successfully retrieved. This code is commonly used when clients make partial content requests, such as when downloading large files in chunks or streaming media.
By receiving a 206 status code, the client can be confident that the requested partial content has been delivered successfully, enhancing the efficiency of data retrieval and transmission.
When the 206 Partial Content status code is received, it indicates that the server has successfully fulfilled a partial content request made by the client using one or more Range HTTP headers.
The server may return the requested data as a multipart document, especially in cases where multiple ranges are specified. However, it's important to note that the server might merge overlapping ranges or those separated by a small gap for efficiency.
Clients should be prepared to handle such responses and understand that the order and number of ranges received may not always match the initial request. In cases where the server cannot fulfill the specified ranges, it may respond with a 416 Range Not Satisfiable status code, or it may return a 200 OK status code with the entire document in the message body.
In this particular sample, the client initiates a request for a specific block of data within a video file, as indicated by the Range header in the HTTP request. The server then successfully responds by providing the requested range of data, explicitly specifying that the data represents an MP4-encoded video. This allows the client to efficiently retrieve and process the targeted portion of the video without needing to download the entire file.
GET /videos/sample.mp4 HTTP/1.1
Host: www.example.com
Range: bytes=25000-75000
Response
HTTP/1.1 206 Partial Content
Content-Type: video/mp4
Content-Length: 25000
Content-Range: bytes 25000-75000/100000
<50,000 bytes of video data will follow>
Alternate response – when the total size was not known by the server
HTTP/1.1 206 Partial Content Content-Type: video/mp4 Content-Length: 25000 Content-Range: bytes 25000-75000/*
<50,000 bytes of video data will follow>
The 206 Partial Content status code is like asking for a specific part of a big file instead of downloading the whole thing.
For example, when you want to watch only a certain segment of a video, this code helps the server send you just that part, saving time and data. It's like getting only the chapters you want from a long book instead of reading the whole book.