Empty HTTP Content-Range Collections and Headers

How can we handle an empty collection on a RESTful interface, the Content-Range header ?

For example, having 42 records, the Range: items=0-41 will return everything, and the response header will be: Content-Range: items 0-41/42 .

However, how can we work with the Content-Range header when there are no records? Thanks for any help.

Edit:

I mean, by returning an empty collection, the server might want to return Content-Range: items xy/0 , where x and y are a value that will be different from 0. But which one? I think this is a sticky question, and the specification does not mention it.

+8
rest pagination paging
source share
2 answers

In fact, the server should respond with HTTP 416 Request Not Satisfiable, Content-Range: */0 .

+5
source

If you get non-zero numbers for XY / 0, then the response from the server is invalid (breaks). Enter an error.

0
source

All Articles