Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 222
T5i Avatar asked Mar 03 '13 01:03

T5i


1 Answers

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

like image 200
T5i Avatar answered Oct 17 '22 06:10

T5i