A stalled model download can leave a useful prefix on disk. HTTP range requests let a client ask for the remaining bytes. The file at the same address may have changed while the download was stopped. Appending bytes from the new file to the old prefix would leave a mixed result.
Save the identity of the partial file
Record the number of bytes already stored and the original response’s strong ETag. An ETag is a server supplied validator for a representation. A weak ETag starts with W/ and cannot be used with If-Range. Keep the URL and representation settings, including content encoding, consistent. Byte positions refer to the representation the server sends. The HTTP specification permits combining partial responses only when they share a strong validator.
If there is no strong ETag, a Last-Modified date works with If-Range only under the specification’s strong validator rules and only when there is no ETag. If that cannot be established, fetch the file again from the start.
Check the resumed response
Suppose the saved file contains N bytes. Request the same resource with Range: bytes=N- and If-Range set to the saved strong ETag. If the representation still matches, the server can return 206 Partial Content. If it changed, If-Range directs the server to ignore the range and return the full representation. MDN’s guide explains these response paths.
For a 206 response, inspect Content-Range before appending. Its starting position must equal N, and its total length must agree with any total already recorded. Check a returned ETag against the saved one. Content-Length describes the returned body, which may be only the remaining part, so it cannot substitute for Content-Range. A 200 response contains a full replacement: save it as a new download instead of appending it. A 416 response means the requested range is unsatisfiable; inspect the file and response before trying again. These checks follow the range response rules.
What to do
- Keep the partial file and its strong ETag together.
- Resume from the exact saved byte count with
RangeandIf-Range. - Append only after a
206response passes the validator andContent-Rangechecks. - Start a fresh file for a
200response or when the saved metadata is missing or inconsistent.
These checks prevent a completed transfer from joining bytes from different versions.

The Campfire
No commentsNobody has pulled up a log by this one yet. Be the first to say what you make of it.
Held for the desk. It appears after a look.