Target file

https://assets.streampdf.com/PDF32000_2008.pdf — 22.5 MB, served with Accept-Ranges: bytes, so both the full GET and byte-range requests work.

1. Start the full GET

fetch() resolves the moment the response headers arrive — the body is still streaming at this point. Nothing is downloaded in full yet.

2. Read a single chunk

response.body.getReader() pulls exactly one chunk. PDF.js does the same: it reads only the bytes the parser actually needs.

3. Interrupt the request

reader.cancel() closes the body stream and the browser drops the underlying connection; controller.abort() aborts the request itself. In DevTools this request turns into 200 (canceled) — the remaining ~22 MB are never transferred.

4. Ask for a byte range instead

The follow-up request asks for the last 1 KB — Range: bytes=(fileSize-1024)-(fileSize-1), which is exactly what PDF.js does when it needs startxref at the tail of the file. It gets 206 Partial Content: one kilobyte instead of the whole file.

Log

Tip: tick Disable cache in the Network panel, otherwise a second run may be served from the browser cache and the download sizes look misleading.