HTTP Status Code 416 – Range Not Satisfiable
The HTTP status code 416 Range Not Satisfiable indicates that the server cannot fulfill the request for a range specified in the Range
header field. This usually happens when the requested range does not match the available data for the requested resource.
Examples
Example 1: Range Exceeds Available Data
Suppose you have a file that is 1000 bytes in size, and a client requests a byte range that starts beyond the size of the file:
GET /example-file.txt HTTP/1.1
Host: www.example.com
Range: bytes=1500-2000
In this case, the server will respond with:
HTTP/1.1 416 Range Not Satisfiable
Content-Range: */1000
The Content-Range
header indicates that the total size of the resource is 1000 bytes, and the requested range is invalid.
Example 2: Invalid Range Syntax
If a client requests a range with an invalid or malformed syntax, such as a negative range:
GET /example-file.txt HTTP/1.1
Host: www.example.com
Range: bytes=-100
The server will respond with:
HTTP/1.1 416 Range Not Satisfiable
Content-Range: */1000
Again, the Content-Range
header clarifies the total size of the file, but the requested range is not satisfiable due to incorrect syntax.
This HTML block provides a comprehensive explanation of the HTTP status code 416 – Range Not Satisfiable. It includes a description of what the status code means, examples of situations where it might be encountered, and a summary to ensure understanding.
Example 1: Example Scenario
# Client sends a request example. GET /example HTTP/1.1 Host: www.example.com # Server Response HTTP/1.1 416 416 Range Not Satisfiable Date: Wed, 09 Oct 2024 23:05:13 GMT Server: ExampleServer/1.0 Content-Type: application/json { "error": "Description of the error for 416" }
Example 2: A Different Scenario
# Client sends another example request. POST /another-example HTTP/1.1 Host: www.example.com # Server Response HTTP/1.1 416 416 Range Not Satisfiable Date: Wed, 09 Oct 2024 23:05:13 GMT Server: ExampleServer/1.0 Content-Type: application/json { "error": "Detailed message for 416" }
Summary
The 416 Range Not Satisfiable status code is used by servers to indicate that they cannot process the requested range from a client due to it being outside the bounds of the available data or due to a malformed range request. Clients should ensure their range requests are within the size of the resource and correctly formatted to avoid this error.