Practical developer guides

HTTP Range requests: verify resumable downloads

Inspect 206, Content-Range and If-Range before joining partial content into a file.

Nav Tools ·

Request a byte interval

A byte range uses inclusive start and end positions. bytes=0-99 requests 100 bytes, not 99.

A server can ignore Range and return the complete response with 200. Inspect the actual status before appending the body.

Range: bytes=0-99
Expected partial response: 206 Partial Content
Content-Range: bytes 0-99/1000

Check the returned interval

Content-Range describes the response bytes and complete length when known. It must match the region your downloader intends to fill.

For an unsatisfiable range, a 416 response can include bytes */length. Do not treat that error body as file content.

Avoid joining different representations

If-Range with a strong validator lets a server return the requested range only if the representation still matches; otherwise it returns a full response.

If the resource changed, restart or replace the partial file instead of appending the new full response.

Range: bytes=100-
If-Range: "artifact-v1"

Verify the complete artifact

Content codings and selected representations can complicate byte positions. A downloader must agree on which representation the ranges describe.

After assembly, compare size and a trusted digest of the intended artifact. The browser HTTP tool is for inspection, not a large-file resume manager.

References

← Practical developer guides