httppaginationhttp-headers

Empty collection and HTTP headers Content-Range


How can we handle empty collection on a RESTful interface, with Content-Range's items header?

For instance, having 42 records, a request Range: items=0-41 would return everything, and the response header would be: Content-Range: items 0-41/42.

However, how can we deal with Content-Range header when there is not any records? Thanks for any help.

Edit:

I mean, returning an empty collection, the server may want to return Content-Range: items x-y/0, where x and y are a value which would be different than 0. But which one? I think this is a sticky question, and the spec does not mention it.


Solution

  • Actually the server should respond with an HTTP 416 Request Not Satisfiable, with Content-Range: */0.