AES Encryption Explained: How It Works and Why It Matters
Jun 23, 2026
4xx Client Error
The 416 (Range Not Satisfiable) status code indicates that none of the ranges in the request's Range header field overlap the current extent of the selected resource. The response should include a Content-Range header indicating the valid range.
When a video player requests bytes 1000-2000 of a file that is only 500 bytes long, return 416 Range Not Satisfiable with a Content-Range header indicating the file's actual size. The client should restart the download from the beginning or adjust its range.
// PHP - handling invalid range requests
$fileSize = filesize('video.mp4');
$range = $_SERVER['HTTP_RANGE'] ?? '';
if (!isValidRange($range, $fileSize)) {
http_response_code(416);
header("Content-Range: bytes */$fileSize");
exit;
}
Mistake: Returning 400 instead of 416 for invalid byte ranges
Fix: Use 416 specifically when the Range header is syntactically valid but the requested range does not overlap the file. Use 400 only if the Range header itself is malformed.
Blog
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026