Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP Range Header for Entity lists

I have resources like this

/entities        # GET, POST
/entities/<id>   # GET, PUT, DELETE

GET /entities gets the list of all entities. Now I want to poll for updates. The case for a single entity is straight forward:

GET /entities/2
If-Modified-Since: <http date>

The list is tricky. I want the response to be a list of entities, updated or created since a given point in time. I'd intuitively use

GET /entities
Range: after <http date>

Which is a valid request by HTTP specification http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.2 . But the spec also mandates a 206 Partial Content response, which has to include a Content-Range header. A Content-Range header, in turn, mandates a byte range to be specified http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16 . This is obviously very inconvenient for my use case.

How would you request a semantic range over HTTP?

like image 616
Bendlas Avatar asked Oct 23 '11 19:10

Bendlas


People also ask

What is Range HTTP header?

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.

What is the range of HTML headers?

HTML defines six levels of headings. A heading element implies all the font changes, paragraph breaks before and after, and any white space necessary to render the heading. The heading elements are H1, H2, H3, H4, H5, and H6 with H1 being the highest (or most important) level and H6 the least.

What should be included in HTTP header?

HTTP headers let the client and the server pass additional information with an HTTP request or response. An HTTP header consists of its case-insensitive name followed by a colon ( : ), then by its value. Whitespace before the value is ignored.


1 Answers

From reading section 14.35.1, I would say that the Range header is used to request a specific range of bytes from a resource, not to request a group of entities according to when they were modified.

In this case, I believe you should treat your range as a filter and pass the date as a query string parameter:

GET /entities?modified-since=<date>
like image 73
Jeff Ogata Avatar answered Oct 08 '22 16:10

Jeff Ogata