Skip to content
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

Interaction between Accept-Query and Allow #2860

Open
hawkinsw opened this issue Aug 7, 2024 · 9 comments
Open

Interaction between Accept-Query and Allow #2860

hawkinsw opened this issue Aug 7, 2024 · 9 comments

Comments

@hawkinsw
Copy link

hawkinsw commented Aug 7, 2024

Hello. I hope that these comments/questions are helpful. If not, please feel free to ignore them.

The QUERY extension says that a server may respond with an Accept-Query header whose value is a list of one or more content types it supports for encoding queries.

  1. How does a server advertise its support for QUERY if it places no restriction on the content type? The grammar for the header value says that at least one content type must be specified.
  2. Should we specify (for the sake of explicitness not correctness) how the Accept-Query header interacts/overlaps with Allow? In particular, does a 405 response that includes an Accept-Query header mean that QUERY does not need to appear in Allow?

Again, I hope that these questions are helpful. If they are, and there is a consensus on how to proceed, I would be more than happy to help draft some changed language. If these are not helpful, please just tell me to go away.

Thanks for your work on this interesting extension!

@martinthomson
Copy link
Contributor

@hawkinsw (hi Will!) asks a good question here.

That made me ask something else:

  1. Can we have an example of Accept-Query?
  2. Can we have an explanation how Accept-Query compares to Accept in a response, and why there is a need for a new field for this purpose.

Of course, the real question is what Will asks: if the resource responds with 405 and lists a number of methods, how do you interpret the Accept/Accept-Query/Accept-Encoding fields of that response? It is entirely reasonable for a resource to support different media types for different methods.

One approach would be to say that managing the matrix of combinations is too difficult. These fields therefore only apply to the specific request that was made. That leads to Accept-* having no real meaning for a 405 response. Under that interpretation, I can't see any reason to define Accept-Query over a straight Accept. This is the most that RFC 9110 says, which isn't much.

@hawkinsw
Copy link
Author

hawkinsw commented Aug 8, 2024

@hawkinsw (hi Will!) asks a good question here.

Hello back!!

That made me ask something else:

1. Can we have an example of Accept-Query?

2. Can we have an explanation how Accept-Query compares to Accept in a response, and why there is a need for a new field for this purpose.

I was wondering this very thing, too. Read what comes next with the caveat that I am not an expert at HTTP semantics but have started added QUERY support to freenginx:

It seemed to me that the Accept-Query response header would be good in a case where a client wanted to discover the server's preferred way of receiving a query. Say that, for example, a web application could accept queries via POST or QUERY but the QUERY used fewer resources (for whatever reason). The client could issue an OPTIONS request to see whether (and in what mime type) the server accepts QUERY requests. If the response did not include an Accept-Query header, the client could fall back to the other means of issuing a query.

Of course, the real question is what Will asks: if the resource responds with 405 and lists a number of methods, how do you interpret the Accept/Accept-Query/Accept-Encoding fields of that response? It is entirely reasonable for a resource to support different media types for different methods.

One approach would be to say that managing the matrix of combinations is too difficult. These fields therefore only apply to the specific request that was made. That leads to Accept-* having no real meaning for a 405 response. Under that interpretation, I can't see any reason to define Accept-Query over a straight Accept. This is the most that RFC 9110 says, which isn't much.

It does seem that there is a pretty interesting matrix of possibilities there. I think that the approach you outline is workable but ultimately it seems to depend on, as you said, whether or not there is an actual reason to define Accept-Query.

PS: A sincere thank you for validating that my question wasn't entirely stupid.

@MikeBishop
Copy link
Contributor

You're correct that Accept-Query adds only one bit of information over Accept -- the fact that the QUERY method is supported on this resource. I'm inclined to say that requiring at least one content type is reasonable, since this is an object the server will need to interpret, not just store. (The same argument could be made for PATCH.) If the server must be able to read it, the server has a list of formats it can interpret, and that can't be wide-open.

Arguably, one could use Accept and then use Allow to advertise QUERY support.

@reschke
Copy link
Contributor

reschke commented Sep 7, 2024

Or we could just re-use the syntax for Accept (https://greenbytes.de/tech/webdav/rfc9110.html#field.accept) which would allow "/". And clients could just re-use their field value parser for "Accept".

@mnot - want to suggest SF syntax?

@mnot
Copy link
Member

mnot commented Sep 7, 2024

It's either a SF or not - you can't both define it as a SF and also re-use existing parsers.

If we go SF, it would either be a List of Strings or a List of Tokens (using Strings when the field name contains disallowed character).

@reschke
Copy link
Contributor

reschke commented Sep 9, 2024

In both case we would use existing parsers, no?

@mnot
Copy link
Member

mnot commented Sep 9, 2024

Yes, as long as it's the right one.

@nicowilliams
Copy link

Suppose you have a resource which allows PUT and QUERY meaning very different things, such that the sets of accepted request body MIME types for those two methods are disjoint, then Accept-<Method> might be a reasonable extension in general, and Accept-Query a reasonable extension in particular. Perhaps then Accept-Query should be generalized to Accept-<Method>.

@zenomt
Copy link

zenomt commented Sep 25, 2024

there are already Accept-Patch and Accept-Post response fields in the IANA HTTP Field Name Registry. i think Accept-Query is valuable for the same reasons those other Accept-<method> ones are, and that its value should be 1#media-type, both for consistency with Accept, Accept-Patch, and Accept-Post, as well as to allow media-type parameters along with the principal type/subtype.

the use case i'm envisioning is advertising support for, say, specialized profiles of a media type, like for example

Accept-Query: application/ld+json; profile="http://zenomt.com/ns/jsonld-terse http://example.com/ns/terse-query"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

7 participants