-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Right Content-range value for 0 results #109
Comments
i had noticed this too and wondered what to do about it. its a great question. since indexing is 0-based, the representation for a result set that contains just a single item would be if we look at the spec
we cannot have so, what should we do if we are showing an empty range? the spec doesn't specifically call out this case but http://stackoverflow.com/a/19695159/251287 suggests a 416 status with
we may have requested items 0-x but none of the items in that range "overlap the current extent" of the resource so 416 is the right response. dstore doesn't support the 416 response but what i have found to work is i think this is a great question and it's worth considering whether or not 416 is the right response according to the spec. whatever the decision is about the way we think the spec means for it to happen, i tend to think that dstore probably doesn't do the right thing currently. |
I am glad I managed to ask a good question :D I am happy with anything :D I really want JsonRestStores to be compatible On 11 March 2015 at 00:08, Ben Hockey [email protected] wrote:
|
Howdy all, I know this is late in to this conversation, but perhaps this will help others who are searching for the same thing.
In my "day job" at HP (now HPE) we wrestled with this as well. We came to the conclusion that the RFCs are ambiguous and somewhat conflicting on the topic, so we changed our question from "what's right?" to "what's least wrong?". FWIW, here's an excerpt from our protocol spec: The The format is
Caution: The About the Content-Range header In a request message, the The format is "unit M-N/Z". The unit is typically "bytes"; M is the 0-based range-start number, N is the 0-based range-end number (inclusive), and Z is the complete-length of the final file's contents. Example:
The length of the content in the message must equal N-M+1. When Empty Files For a request, to indicate an empty (zero-byte) file or resource with the Content-Range, use Z=0. Thus, anything that is /0 means the empty file (or resource or page) ...[irrelevant section of spec omitted].... The M and N values SHOULD still be provided for a request message. However, for a response message to indicate an empty file, the shorter notation Zero-length Content Range To indicate a zero-length content, use the special case "1-0". Because the computed length is N-M+1, this evaluates to a range length of zero. Note that this does not mean the file is of zero length (that's indicated with /0), just that this chunk is empty. A zero-length range is not an error. Additionally, any M-N combination with M and N >=0, where N-M+1=0 is valid – for example 7-6 – but that would be confusing, and is unnecessary, so an implementation SHOULD NOT do this. A typical use case of a zero-length range is when beginning a resumable upload (UC3) to get back a handle or to "initialize" the file, but without sending any of the file. For example, 1-0/12345. Some users have suggested using the range M=0 and N=-1, n.b. 0--1 ("zero" "dash" "minus" "one"). This is forbidden by some HTTP RFC's and results in an error from many web servers, because the start and end ranges are specified as only digits without a sign (The BNF is Using Wildcards in Content-Range In a request message, the range-start number M may be specified as an asterix '*'. For example, *-9999. This means that for new resources, it's zero, and for existing resources, it's the current size of the file/page/resource. In code, this is expressed as Also in a request message, the range-end number N may be specified as an asterix '*', such as ...[section of spec omitted]... In a request, the complete-length Z may also be specified as an asterix "", such as 1000-9999/ . This means that the complete size is not yet known (or need not be specified at this time). However, to finalize a transfer, the Z must be specified. Thus, in a request message, About the Content-Length header When both A Content-Length without Content-Range implies a content range of 0 to L-1, and that Z == L. Note this is not true for |
At the moment, in JsonRestStores (which I am finalising as we speak), when there are NO results I am returning:
I realise that dstore only really cares about the last bit to return the
total
. However, it bothers me that `0-0/0' is actually telling the client "the first record out of 0 results", which is not formally correct.Do you think
0-0/0
is the way to go? If not, what should I return?The text was updated successfully, but these errors were encountered: