HTTP Headers for Entity Lists

I have resources like this

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

GET / entities gets a list of all objects. Now I want to poll for updates. Case for one object directly:

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

The list is complicated. I want the answer to be a list of entities updated or created from a specific point in time. I would intuitively use

 GET /entities Range: after <http date> 

What is a valid HTTP specification request http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.2 . But the spec also sets the response to 206 Partial Content , which should include the Content-Range header. The Content-Range header, in turn, sets the range of bytes that should be specified http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16 . This is obviously very inconvenient for my use.

How do you request a semantic range over HTTP?

+6
source share
1 answer

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, rather than requesting a group of objects according to when they were changed.

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

 GET /entities?modified-since=<date> 
+2
source

Source: https://habr.com/ru/post/899923/


All Articles