416 Range Not Satisfiable
HTTP response status code 416 Range Not Satisfiable is a client error that is returned by the server to indicate that the range or ranges specified by the client were not retrievable. None of them overlap with the available data and hence, does not make sense, given the nature of the resource.
Usage
When the 416 Range Not Satisfiable error message is received, it implies the client has requested partial content, using the Content-Range header. For ranges of bytes, if the first byte of the specified range was greater than the length of the sequence, then this error message will be returned.
One of the reasons that partial ranges are requested is large file transfers, where the client wants to download a file in chunks. Using Content-Range in the request header, a file can effectively be downloaded in pieces and any order.
When the server can satisfy the request and return at least one of the requested ranges as a subset of the resource, it will return 206 Partial Content to indicate success. Servers have the option to ignore range requests and in turn, may return the resource in its entirety and the 200 OK status along with it.
As part of the response, the server will create a Content-Range header, which specifies the current length of the data. This will be in the form of:
Content-Range: 100-250/75000
This line specifies that bytes 100 through 250, for 150 bytes in total, have been returned, and the total size of the resource is 75,000 bytes.
If there is an asterisk ‘*’
before the delimiter ‘/’
then it indicates an unsatisfiable range.
Note
Search engines like Google will not index a URL with 416 Range Not Satisfiable response status, and consequently, URLs that have been indexed in the past but are now returning this HTTP status code will be removed from the search results.
Example
In the example, the client requests bytes 1000 through 2000 of a resource. However, the server cannot satisfy this because the file is only 512 bytes long. As such, the 416 Range Not Satisfiable error message is returned. Using the information returned from the server about the total size of the resource, the client has the option to recreate and resend the request with a valid range.
Request
GET /documents/main HTTP/1.1
Host: www.example.re
Content-Range: bytes=1000-2000
Response
HTTP/1.1 416 Range Not Satisfiable
Content-Range: bytes */512
Alternative response – Server chooses to ignore range
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 512
<entire 512 bytes in message body>
Code references
.NET
HttpStatusCode.RequestedRangeNotSatisfiable
Rust
http::StatusCode::RANGE_NOT_SATISFIABLE
Rails
:requested_range_not_satisfiable
Go
http.StatusRequestedRangeNotSatisfiable
Symfony
Response::HTTP_REQUESTED_RANGE_NOT_SATISFIABLE
Python3.5+
http.HTTPStatus.REQUESTED_RANGE_NOT_SATISFIABLE
Apache HttpComponents Core
org.apache.hc.core5.http.HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE
Angular
@angular/common/http/HttpStatusCode.RangeNotSatisfiable
Takeaway
The 416 Range Not Satisfiable status code is a client error that will be returned if the partial Range Request sent by the client does not make sense for the given resource. The server has the option to ignore HTTP range requests and send the entire resource.