I've searched a lot but I can't find a good answer to this question. Being a HATEOAS aficionado, I would think that this header fit perfectly:
Range: item=1-20/100
In the HTTP spec, I don't understand some "contradictions": The range unit can accept "other-range-unit"...
range-unit = bytes-unit | other-range-unit
bytes-unit = "bytes"
other-range-unit = token
... yet the spec is later explicit:
The only range unit defined by HTTP/1.1 is "bytes". HTTP/1.1 implementations MAY ignore ranges specified using other units.
Finally the spec ends with this statement:
HTTP/1.1 has been designed to allow implementations of applications that do not depend on knowledge of ranges.
NB: I don't care about "browsability".
The Range HTTP request header indicates the part of a document that the server should return. Several parts can be requested with one Range header at once, and the server may send back these ranges in a multipart document. If the server sends back ranges, it uses the 206 Partial Content for the response.
You can paginate the JSON response that is called from the REST API. The order of the data is retained from page to page. Given the ability to paginate, you can quickly populate tables and make new REST calls every time you go to the next page of the data on the table.
An HTTP range request asks the server to send only a portion of an HTTP message back to a client. Range requests are useful for clients like media players that support random access, data tools that know they need only part of a large file, and download managers that let the user pause and resume the download.
The Content-Range HTTP header is a response header that indicates where a partial message belongs in a full body massage. This header is sent with a partial entity-body to specify where in the full entity-body the partial body should be applied. Directives: <unit>: This specifies the unit of content range.
Here the answers that I gently borrowed from this question thanks to @ptidel: Content-Range header - allowed units?.
First, custom units are proposed in this draft HTTP/1.1, part 5: Range Requests and Partial Responses
Second, there is a subtle difference, the first statement has been made for parsing purpose
range-unit = bytes-unit | other-range-unit
bytes-unit = "bytes"
other-range-unit = token
While the second statement has been made for producing HTTP request.
Finally, the whole comment from Ferenc Mihaly summarizes perfectly the situation:
I conform to the HTTP spec when I'm sending [a custom range unit] and they conform to HTTP when they ignore it
WebDAV uses HTTP extensions correctly, IMO, but rarely works over the Internet for exactly this reason
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With