Your Download Asked for a Range. Why Did the Server Send Everything?
A Range request can receive a full 200 response. Validate status, Content-Range and representation identity before appending a resumed download.
The download says “resuming,” the request contains Range: bytes=1024-, and the response is 200 OK. If your downloader appends that body to the first 1,024 bytes it already saved, the result can be larger than the original file. Very thorough downloading. Slightly less thorough file integrity.
The useful answer is to choose the write mode from the response, not from the request you intended to send. A server can ignore a Range request and return the complete representation. Append only a validated partial response that belongs to the same representation and starts at your stored offset. A full 200 response needs a fresh destination, not append mode.
This is an AI-prepared, documentation-based explainer, not a personally reproduced incident. Requests, numbers and outcomes below are illustrative and unexecuted. See the editorial policy.
The suspicious clue is where the response starts
Imagine a 4,096-byte artifact. You saved bytes 0 through 1023 before the connection stopped. Your next request asks for bytes=1024-. Under a straightforward, unchanged, single-range response, you'd expect 206 Partial Content and Content-Range: bytes 1024-4095/4096.
Those numbers tell a coherent story: the body begins exactly where your local prefix ends. If the server instead sends the full 4,096-byte representation and your code appends it, the local file becomes 5,120 bytes. That's arithmetic for this illustrative scenario, not a measured incident. The network can deliver every byte correctly while the client assembles the wrong file.
RFC 9110's Range rules allow a server to ignore Range. That makes “the server returned 200” an observation to investigate, not sufficient proof that a proxy broke the protocol. Check the request that reached the serving endpoint, then check the status and headers that actually came back.
A helpful header isn't a promise
Accept-Ranges: bytes is useful evidence about support. It isn't permission to append the next response without looking. The Accept-Ranges contract doesn't guarantee every future request will receive partial content. Conversely, the absence of that advertisement doesn't prohibit a client from requesting a range.
Keep the method in view, too. Range handling in RFC 9110 is defined for GET. A HEAD probe can help inspect metadata, but it doesn't exercise the same partial-body behavior. Don't turn a HEAD response into a failed resume test and start changing the server configuration on that evidence alone.
For an endpoint you control, an illustrative inspection request can keep the body away from the existing partial file:
curl --range 1024- \
--dump-header resume.headers \
--output resume.body \
https://example.invalid/artifact.binReplace the example URL with your endpoint. The curl range option requests the range; it doesn't make an arbitrary server honor it. This command writes a separate body for inspection. It isn't a complete downloader or a command to concatenate files.
The same URL can name different bytes
There's a more subtle failure than receiving the whole file twice. The resource might change between the interrupted transfer and the retry. A well-formed range starting at byte 1024 of version B doesn't complete a prefix saved from version A.
Save the representation's identity with the partial file; the rules for combining parts require a shared strong validator. A strong ETag is useful here. If-Range lets a client ask for the remainder conditional on that identity. If its validator no longer matches, the server ignores the range and can send the full representation instead. That full response is how the client learns to restart, rather than splice versions together.
Use the actual saved strong ETag, not a token invented from the URL or file size. A weak ETag, marked with W/, isn't valid for If-Range. HTTP-date validators have additional strength requirements; don't assume any Last-Modified timestamp is an interchangeable substitute.
Representation details matter as well as names. Byte ranges apply to the encoded representation when a content coding is used. If the HTTP library transparently decompresses data before saving it, a local decoded byte count may not be a usable wire-range offset. Inspect content coding and library behavior; keep the stored bytes and resume metadata consistent.
Make the response choose the next state
For a downloader that requests one remaining byte range, a review table is more useful than a generic “request succeeded” branch:
| Response | Decision before writing into the saved artifact |
|---|---|
| 206 with the expected Content-Range | Validate the start offset, representation identity and body completeness before combining. A 206 label alone isn't enough. |
| 200 with a full representation | Write a new complete candidate, validate it, then replace the partial download. Don't append it. |
| 416 Range Not Satisfiable | Reconcile the current representation length and identity. Don't mark the file complete solely from this status. |
| Error, unexpected redirect target or incomplete body | Preserve a known-good prefix and its metadata; resolve the failed assumption before promoting a result. |
The Content-Range field describes the part and, when known, the complete length. On a partial response, don't mistake the transferred body's length for the whole artifact's length. Check offsets explicitly and handle an unknown total deliberately.
For 416, a response can report the selected representation's current length. Equal length is still not proof your local bytes match it. Where a trusted manifest supplies a digest, verify that digest before promoting the artifact. File size is a useful clue, not a personality test for identical content.
Test the fallback, not just the happy resume
A proposed test fixture should return an expected 206, ignore Range with a full 200, change its strong ETag between attempts, and end a body prematurely. Also exercise 416 and whatever content-coding behavior your client actually uses. These are suggested tests; none was executed for this article.
Assert the final bytes and metadata, not just the status code or progress percentage. Keep the partial file until a replacement passes validation. A download that ends at 100% can still be a very confident collection of the wrong bytes.
This is related to, but different from, the If-Match and 412 write-precondition problem. Here you're deciding whether bytes can be combined, not protecting a write. The retry review asks the broader question of what repeating an operation changes. More protocol investigations are collected in the HTTP archive.
Put the response-validation branch beside the code that opens the destination file. Before append mode is reachable, the code should establish exactly which bytes it's about to attach to exactly which saved representation.