httpwg / http-extensions

HTTP Extensions in progress
https://httpwg.org/http-extensions/
433 stars 143 forks source link

QUERY: Query body normalization is a bad idea #2896

Open nicowilliams opened 1 week ago

nicowilliams commented 1 week ago

See discussion in HN thread.

nicowilliams commented 1 week ago

It might be a good idea to have a NORMALIZE method for requesting that the server normalize a QUERY body.

Basically, client-side normalization is going to be heavily dependent on the query MIME type. Do MIME registrations even provide normalization functions? Well, the registrations are fairly free-form, so that question is probably not relevant.

When JSON normalization has been discussed before it's proven to be an extremely tricky topic.

Server-side normalization, however, is much more likely to be possible, especially if the server parses a query into an AST, as then a canonical representation of the AST should be possible without having to specify any details in any RFCs.

reschke commented 1 week ago

Are you suggesting to add text about normalization? Precisely where?

nicowilliams commented 1 week ago

OLD:

The cache key for a query (see Section 2 of [HTTP-CACHING]) MUST incorporate the request content. When doing so, caches SHOULD first normalize request content to remove semantically insignificant differences, thereby improving cache efficiency, by:

  • Removing content encoding(s)
  • Normalizing based upon knowledge of format conventions, as indicated by the any media type suffix in the request's Content-Type field (e.g., "+json")
  • Normalizing based upon knowledge of the semantics of the content itself, as indicated by the request's Content-Type field.

    Note that any such normalization is performed solely for the purpose of generating a cache key; it does not change the request itself.

NEW:

The cache key for a query (see Section 2 of [HTTP-CACHING]) MUST incorporate the request body.

Caches SHOULD perform query normalization when possible when constructing cache keys. The extent to which query normalization can be performed, and how, is either a local implementation detail or a detail of the request body's MIME type, but note that at the time of this writing MIME type specifications and registrations do not typically include any normalization functions.

reschke commented 1 week ago

I disagree.

This is an implementation detail. A server can normalize based on how it uses the media type. No public spec is required here.

nicowilliams commented 1 week ago

Yes, the server can normalize however it wants and it's a local detail for it. But caches need not be located in the server, and caches may not be able to normalize the same way as the servers.