206 Partial Content status code indicates that the server is sending only a portion of the requested resource. This status code is commonly used when the client has sent a
Range header in its request, indicating that it only wants a specific portion of the resource.
Here’s a breakdown of its meaning and usage:
- Partial Content Delivery: Instead of sending the entire resource, the server sends only the part (or parts) specified by the client.
- Resume Interrupted Downloads: One common use case for the
206status code is when a large download is interrupted, and the client needs to continue downloading from where it left off. By sending a
Rangerequest, the client can request the remainder of the file without starting from the beginning.
- Adaptive Streaming: Another use case is adaptive streaming of multimedia content. As the network conditions change, a video player might request different portions of a video file at different quality levels.
- Response Headers: When responding with a
206 Partial Contentstatus, the server will also include a
Content-Rangeheader to specify which part of the resource is being sent.
For example, if a client requests bytes 1000 to 1999 of a document, the server response might look like:
HTTP/1.1 206 Partial Content Date: ... Content-Range: bytes 1000-1999/5000 ... [bytes 1000-1999 of the resource]
In this example,
/5000 indicates that the entire resource is 5000 bytes in length, and the server is returning bytes 1000 to 1999 as requested by the client.
It’s important to note that not all servers support partial content requests, and not all resources are available for partial content retrieval. If a server cannot or does not want to fulfill the range request, it can respond with the entire resource and a
200 OK status, or in some cases, it might respond with a
416 Range Not Satisfiable status if the requested range is invalid for the given resource.
What are HTTP status codes?
HTTP (HyperText Transfer Protocol) status codes are three-digit responses that a server returns in response to a client’s request. These codes indicate whether the request was successful, encountered errors, or requires further action. HTTP status codes are standardized and documented in various RFCs (Request for Comments).
Here’s an overview of the classes of HTTP status codes, and a few examples of specific codes:
- 100 Continue: The server has received the request headers and the client should proceed to send the request body.
- 101 Switching Protocols: The requester has asked the server to switch protocols.
- 200 OK: Standard response for successful HTTP requests.
- 201 Created: The request has been fulfilled and has resulted in a new resource being created.
- 204 No Content: The server has successfully processed the request and there is no further content to send in the response.
- 301 Moved Permanently: The URL of the requested resource has been changed permanently. The new URL is provided.
- 302 Found: The URL of the requested resource has been changed temporarily. New changes in the URL might be made in the future.
- 304 Not Modified: The resource has not been modified since the last request.
4xx: Client Errors
- 400 Bad Request: The server cannot process the request due to a client error (e.g., malformed request syntax).
- 401 Unauthorized: The request has not been applied because it lacks valid authentication credentials for the target resource.
- 403 Forbidden: The server understands the request, but it refuses to authorize it.
- 404 Not Found: The server can’t find the requested resource.
5xx: Server Errors
- 500 Internal Server Error: The server encountered a situation it doesn’t know how to handle.
- 502 Bad Gateway: The server was acting as a gateway or proxy and received an invalid response from the upstream server it accessed in attempting to fulfill the request.
- 503 Service Unavailable: The server is not ready to handle the request. This can be due to maintenance or overloading.
- 504 Gateway Timeout: The server, while acting as a gateway, did not receive a response in time from the upstream server or some other auxiliary server it needed to access in order to complete the request.
These status codes provide quick, standardized insight into what is happening with a given HTTP request and are vital for troubleshooting issues with HTTP requests and responses.
Published on: 2023-09-28
Updated on: 2023-10-03