-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Do not respond with Content-Range
header unless Range
is requested
#3921
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No 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? No Sign in to your account
Comments
Would doing this imply a breaking change?
Another option instead of another header could be to put it as part of a custom content type: Additionally, with aggregates and spreads maybe there could be a way to return both the root count and the data in the same response. |
I don't quite understand why we would need to return it for other status codes, can you elaborate?
The issue explicitly mentions cutting off embedded results - which this proposal does not help at all with. Any header-based solution is going to be problematic for embeddings. We can only solve the embedding problem by putting the count in the body, imho. I don't see how a custom header can help here. The requirements of this issue are very specific - the Content-Range header should be returned correctly - which we don't do, yet. Returning.. another header instead, is not going to fix that. I don't think we will improve HTTP compliance by introducing a custom header :D I don't quite see, yet, how adding a third way of counting to the mix helps the situation. We already have Range and limit/offset, with potentially different semantics. Adding even more will only make it even more complex, right? I don't see the upside of this proposal, yet. |
Yes.
HTTP compliance would be improved by removing
I think you mean "why wouldn't we", because we are returning other status codes. The RFC said:
It has no meaning for responses other than This proposal is more about removing I also think it would easier to finish my work on #3578 with this change. |
Well, in terms of REST specs, the X-Total-Count has no meaning, too. So why return the same information in two different headers? This is about as bad UX as The RFC just says that the headers don't carry any meaning in terms of their RFC. But that doesn't mean it's forbidden to return them, right? So what is really bad about the fact that we currently return them everywhere? I don't get it, yet. |
While fixing #3007, in #3578 it changes the result of |
X-Total-Count
headerContent-Range
header unless Range
is requested
This seems like either a tooling problem or a problem with how we write the tests, to me. But realistically, we should not be changing something around this header ever so often, that this becomes a problem to adjust in as many tests. If we do #3007, then yes we have a bigger change. But we'd have exactly the same kind of change just by doing this issue here. So it doesn't really matter where we have the big effort, if we only have it once. |
Right. It doesn't seem to forbid the use of Still, my original idea was to not return any header (remove |
I don't think this would satisfy the requirements of the RFC cited above, assuming that we'd still return with 200 here and not 206. I.e. if we return the full response even though a Range was requested. So if we were strict, we'd return 200, but no Content-Range, even in the case when this Range is explicitly requested. |
It would be great to have this fixed to avoid the requirement of a reverse proxy in front. For example react native and expo mobile apps refuse to work with postgrest. |
Problem
Currently we are returning
Content-Range
header on every request.$ curl -i localhost:3000/items HTTP/1.1 200 OK Content-Range: 0-14/*
RFC says
The
Content-Range
should only be returned as a response to aRange
request.Solution
A more appropriate header for returning response length should be
X-Total-Count
as mentioned in this Stackoverflow question. It is a custom header so we can also tweak it.This might help fix other related issues as well:
limit
andoffset
with theRange
header #3007The text was updated successfully, but these errors were encountered: