What is an HTTP range request?
Useful first: HTTP · optional, not a requirement
Choose your depth
Stay with the essentials, or look closer.
YOUR GOALExplain why a client might request only part of a file.
Ask for the missing piece
A download does not always need to start over
Imagine saving the first part of a large illustrated manual before your connection drops. A downloader can ask the server for the remaining bytes instead of asking for the entire manual again. That request for a particular portion is an HTTP range request.
The same idea helps a tool read one section of a large data file or a media player fetch a needed portion. A byte range identifies positions in data; it does not automatically identify a chapter or a moment in a video.
[1] [2]Check what actually arrived
A server may send the requested portion, send the complete resource, or report that it cannot satisfy the range. The downloader has to distinguish those outcomes before using the response.
Think of asking someone to send the missing pages of your manual. If they send a complete replacement, adding it after your saved pages would duplicate the beginning. Resuming a download needs the same care, and the manual must still be the same version.
The HTTP request and response guide explains the underlying exchange.
[1] [2] [6]Ask for a portion, then verify what the server sent.
A range request guarantees that only the missing bytes will be downloaded.
Range support is optional. The client must inspect the response and handle a complete replacement or an error.
Show the explanation
Treat the response as a complete replacement, rather than blindly appending it. A range request does not guarantee a partial response. Appending a complete replacement would duplicate the portion already saved.
YOUR GOALInterpret a single byte range and distinguish 206, 200 and 416 responses.
Read the byte positions and response
Count from zero, including both ends
Suppose the selected file representation is exactly 1,000 bytes long, with positions 0 through 999. A GET request with Range: bytes=200-299 asks for 100 bytes: 299 minus 200 plus 1.
bytes=800-asks for bytes 800 through the end.bytes=-200asks for the last 200 bytes.- For this 1,000-byte example, those last two requests select the same portion.
The dash placement matters: a starting position and a suffix length are different instructions.
[2]Match the response to the request
If the server fulfills the 200–299 request as one range, a response can contain these headers:
HTTP/1.1 206 Partial Content
Content-Range: bytes 200-299/1000
Content-Length: 100Range expresses what the client wants. Content-Range identifies the returned interval and the total representation length. Here, Content-Length describes the 100-byte response body, not the 1,000-byte file.
A 200 OK response can instead carry the complete representation when the Range request is ignored. Do not decide whether to append data from the request header alone.
Recognize a range outside the file
For the same 1,000-byte representation, Range: bytes=1000- starts past its last byte. A server processing that unsatisfiable request can return 416 Range Not Satisfiable with Content-Range: bytes */1000.
The asterisk says that no interval is being reported; 1000 is the current total length. Recheck the saved offset and current file before trying again. A 416 does not mean that the URL is missing, and malformed requests do not all have to produce this one status.
[5] [4] [7]Use the status and Content-Range together to understand a partial response.
bytes=200-299 requests 99 bytes.
Both endpoints count. Subtract the first position from the last and add one: 299 - 200 + 1 = 100.
Show the explanation
100 bytes at positions 200 through 299, from a representation totaling 1,000 bytes. Byte positions are zero-based and inclusive. The interval has 100 bytes; the number after the slash is the total representation length.
YOUR GOALUse validators and response metadata to avoid assembling incompatible byte sequences.
Resume without mixing representations
A support hint is not a promise
Accept-Ranges: bytes advertises byte-range support for the resource. A client may still send Range without having seen that header, and seeing it does not guarantee a later partial response.
Support or the representation can change between requests. Build a response-handling path for partial content, a complete response and failures rather than assuming a previous advertisement settles the next request.
[7]Bind a resumed request to the saved version
Suppose you saved bytes 0–799 together with the strong ETag "manual-v1". A resumable GET can include:
Range: bytes=800-
If-Range: "manual-v1"If that validator still matches, the server can process the range. If the current representation has changed to "manual-v2", the If-Range condition fails and the range is ignored; an otherwise successful GET returns the complete current representation with 200.
The practical consequence is to replace the saved version instead of joining its old beginning to a new ending. Inspect Content-Range before placing a partial body. Do not use a weak ETag such as W/"manual-v1" in If-Range. Validators also appear in HTTP caching, but this example uses one specifically to control resumption.
Ranges address representation bytes
With HTTP content compression, range offsets refer to the encoded representation, not positions in the decompressed text. Do not reuse a byte offset from one encoding as if it identified the same place in another.
A request can also ask for more than one interval. When a 206 response carries multiple parts, it uses multipart/byteranges, and each part has its own Content-Range. Read those parts instead of treating the whole body as one continuous file slice.
Servers can combine nearby ranges or ignore or reject excessive range sets. Requesting many tiny slices is not a universal way to make a download faster.
[2] [3] [7]Resume a specific representation, not merely a URL at an offset.
A URL and byte offset are enough to safely resume any download.
The representation may have changed. Retain an appropriate validator, keep track of the representation and interpret the returned status and range before combining data.
Show the explanation
The range is ignored and the complete current representation is returned; do not blindly append it to the old prefix. A failed If-Range condition causes the range to be ignored. A complete new representation must not be combined with a prefix from the old one.
Keep asking. Check the details.
Source-checked using AI (OpenAI Codex) on . The checks covered sources, examples, and quizzes for this article version.
No human review is claimed. AI review can miss errors; check the original sources below.
- MDN — HTTP range requests
- MDN — Range header
- MDN — 206 Partial Content
- MDN — Content-Range header
- MDN — 416 Range Not Satisfiable
- MDN — If-Range header
- RFC 9110 — Range requests