{"canonical_url":"https://engineer.company/glossary/http-range-request/","content_markdown":"# HTTP range request\n\n## What it is\n\nAn HTTP range request asks a server to send part of a selected representation.\nFor a byte range, the client names one or more portions of the representation's\ndata. A reader can request the beginning of a large file, continue an\ninterrupted download or retrieve the part that contains information it needs.\nThe server chooses whether to support the request and describes the result\nthrough response status and headers.\n\nFor a successful partial response to a single byte range, status 206 indicates\nthat the body is partial. Content-Range describes which bytes it carries and can\ngive the full length where known. A multiple-range response can use a multipart\nbody with details for each part. A server that ignores the range can deliver a\ncomplete response with status 200. The client has to interpret the actual\nresponse before deciding how to store the bytes.\n\nThe ranges refer to bytes of the selected representation. A client that joins\npieces from different versions can produce a damaged file. An appropriate\nvalidator or an If-Range condition can help tie a resumed transfer to the\nversion the client already has. If the condition no longer holds, the client may\nneed to replace its previous partial copy with the newly delivered complete\nrepresentation.\n\n## Why it matters\n\nLarge resources can be expensive to transfer repeatedly. A reader may open a\ndocument on a connection that drops briefly and want to continue after\nreconnecting. A media player can want to seek ahead. Partial transfer supports\nthose experiences when both ends agree about the resource and its byte layout.\nCorrect handling preserves the user's progress across interruptions and\nversions.\n\nThe service also has to handle ranges at the same boundary that ordinarily\nserves the file. Access rules apply to the operation before selecting a portion.\nA proxy or cache can affect which bytes represent the resource and what metadata\nthe client receives. Test the public path separately from direct storage access.\nInclude the transformations and conditions a real client encounters when it\nrequests a range.\n\nClients differ in what they require. One reader can use a full response when\npartial transfer is unavailable. Another may use several requests during a\nclient-side operation. Document the choices that the service supports and check\nhow clients respond when it refuses or ignores a range. Reliable downloads need\na coherent plan for the whole request lifecycle.\n\n## What it looks like in practice\n\nImagine a public route serving a generated PDF. Begin with a normal GET to\nrecord its media type, length and validator. Request a small interval within the\nfile and inspect the response. If the server supports the request, compare the\nreturned bytes with the corresponding part of the complete file and check the\ndeclared positions. If the server sends a full response, verify that the client\nreplaces the partial file with the complete response.\n\nTest a later request after changing the representation through the normal\nrelease path. Keep an earlier partial copy and send the condition the client\nwould normally use to resume. The result should establish whether those earlier\nbytes still belong to the current representation. Add an interval past the end\nof the file. A server can respond with 416 when the requested ranges are\nunsatisfiable. A client should handle that result and find out whether its local\nfile is already complete or needs a new transfer.\n\nEngineer's\n[PDF print stylesheet case study](/portfolio/built-a-637-line-print-stylesheet/)\ndescribes making document exports readable and predictable on paper. Partial\ntransfer is a different property of delivering a generated document. The\nillustrative check ties it to the exact PDF bytes through the public route. It\nalso verifies a useful fallback for clients that receive the whole file.\n\nWhen a cache is on the route, test both an initial full retrieval and a partial\nrequest starting from an empty cache. Record which layer responded and whether\nthe validator and returned interval agree. A status code without a byte\ncomparison gives weak evidence about which part actually arrived at the client.\n\n## Where it goes wrong\n\nA download program can append every response to the bytes it already has. When\nthe server replies with a fresh full representation, the resulting file can\ncontain two versions. Branch on the response status and validate the returned\npositions before appending. If the server reports a different representation\nidentity, begin with a new output or follow the documented recovery policy.\n\nCompression can make range checks confusing. A transfer can select a different\nrepresentation from the stored one when the request changes its accepted\nencoding. The recorded byte positions have meaning only for the bytes they\ndescribe. Keep request conditions and relevant selection headers together and\nexercise the variant that the real client uses.\n\nA downloaded slice can be checked using both content and arithmetic. For a\nsingle returned range, the positions are inclusive, so an interval from position\nzero through position nine should carry ten bytes. Compare the expected length\nwith the bytes actually received and confirm the positions match what the client\nwill append or display. A test that checks only the total length can miss an\ninterval of the right size from the wrong part of the file.\n\nFinally, handle bounded and exceptional inputs. Some clients ask for several\nranges. A service can choose limits and report a result appropriate to its\nactual support. Include a normal interval, an invalid or unsatisfiable one and\nan interrupted response in the test suite. Give operators evidence about\nrepresentation identity and final file integrity, since those are what make a\nsuccessful partial response useful.\n\n## Further reading\n\n- [RFC 9110 range requests](https://www.rfc-editor.org/rfc/rfc9110.html#section-14).\n  Defines range fields, conditions and partial content semantics.\n- [Mozilla's HTTP range requests guide](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Range_requests).\n  Explains practical partial transfers and responses.\n- [libcurl CURLOPT_RANGE](https://curl.se/libcurl/c/CURLOPT_RANGE.html).\n  Documents one way clients request a range.\n\n\u003chttps://engineer.company/glossary/http-range-request/\u003e\n","date_modified":"2026-11-25T07:18:46Z","description":"Follow a byte-range request for a PDF, from the partial response to validation and recovery when a server sends the whole file.","formats":{"gemtext":"https://engineer.company/glossary/http-range-request/index.gmi","gopher":"https://engineer.company/glossary/http-range-request/gophermap","html":"https://engineer.company/glossary/http-range-request/","json":"https://engineer.company/glossary/http-range-request/index.json","markdown":"https://engineer.company/glossary/http-range-request/index.md","pdf":"https://engineer.company/glossary/http-range-request/index.pdf"},"kind":"page","language":"en","title":"What is an HTTP range request?","url":"https://engineer.company/glossary/http-range-request/","version":1}