Upcoming new HTTP QUERY method
datatracker.ietf.org
datatracker.ietf.org
Upcoming new HTTP QUERY method - https://news.ycombinator.com/item?id=30153995 - Jan 2022 (51 comments)
- why not just extend GET to make a payload not "undefined" anymore? Instead now people have to wonder whether to use GET or QUERY. The non-idempotent methods have at least a difference in semantics, while this here seems mostly another way to provide parameters for essentially the same action.
- QUERY is a somewhat bad name choice, given that URL parameters are also refered to as query string
I wish standards bodies weren't afraid of angering the feet-dragging vendors who haven't had to update their shitty middleboxes in 20 years despite charging their customers through the nose for them. Maybe it would be better for a healthier web if these dinosaur machines got broken once in a while.
I would expect that the majority of all GET requests are non public-facing.
So needlessly breaking all of these machines would have little to no user benefit.
It’s easier to define semantics for a new method than to expect everyone to change how an existing methods is handled by all existing software.
Slightly confusing, I agree. But given that neither are called just "query", and HTTP methods being usually in all caps, I think it won't be as bad. "Query component" (from URIs as specced) VS "QUERY method" should be clear enough.
9 to be precise (RFC 7231 defines GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE, RFC 5789 defines PATCH).
Some of those are not commonly used because of various security vulnerabilities that have been discovered over the years (see https://www.kb.cert.org/vuls/id/867593, https://www.kb.cert.org/vuls/id/288308, https://www.kb.cert.org/vuls/id/150227) for some examples.
Some tooling goes as far as defining some of those methods as "forbidden", like what the standard for JavaScript Fetch does.
> 9 to be precise
You are off by 30:
https://www.iana.org/assignments/http-methods/http-methods.x...
Granted, I guess you could argue that because you can use whatever method you want in practice, there is a unlimited set of methods available (depending on how long string whatever server you're using could create, if they are parsing it and so on)
That has always driven me crazy
SEARCH and REPORT, which are probably better names, were already taken by WebDAV, a pre-REST style protocol layered over HTTP that loved (loves?) registering new HTTP methods.
However, just as with POST requests, it might make sense for the server to respond with a redirect to a URL that could be shared.
That said you should be able to trigger any custom HTTP request your browser support via pasting/bookmarking a `data:` or `javascript:` construction if you really want. As of now the URL bar is GET only when you enter a URL.
Just as a small remark, HTTP protocol standards do - or have at least - considered URL input so far in a wider, client-side meaning. Some details are left for the clients, e.g. it differs across browsers how certain URL characters are interpreted when entered into the URL bar (or on the command-line, e.g. with curl(1)).
Apart from that, HTTP URLs are part of the same HTTP standard, aren't they?
I can definitely see why this could benefit his work (at Cloudflare) a lot since it would enable caching of results currently done through POST queries.
[1]: https://stackoverflow.com/questions/978061/http-get-with-req...
But it does lead to unexpected behavior. Users are trained to copy/paste links and send them. If the body only included stuff like auth tokens then it would be ok, but if relevant query stuff was in there (like page size, for example) that would lead to different results that would ultimately be deleterious IMHO.
[2]: https://www.elastic.co/guide/en/elasticsearch/reference/6.8/...
I hope this does not mean that this will be taken as the default method of querying.. A JSON query object could've been nice as an example.
How should you handle conflicting parameters (form-encoded + body)?
Also, on the HTML side.. If it's extended to <form method=QUERY>.. how will you be able to distinguish between the query part and the uri part?
How can/should you copy/share links? Will browsers simply base64 encode this somewhere?
> The non-normative examples in this section make use of a simple, hypothetical plain-text based query syntax based on SQL with results returned as comma-separated values. This is done for illustration purposes only. Implementations are free to use any format they wish
As for copying/sharing links, I think that was covered in another discussion above: Just like with POST, it's likely just not intended to do QUERY requests via links or through the URL bar.
I’m already seeing implementors failing at following the spec here – they will equate the QUERY method to querying a mutable database, which won’t give reproducible results, and to give reproducible results the server would need to save it. Now to make it idempotent, will be an ad-hoc decision of each server. It seems contradictory. At this point it’s indistinguishable from a PUT on a resource that represents the query itself.
I’m not seeing the point of the new method.
As in "increase counter by 1" is not idempotent, "set counter to 2" and "set counter (monotonic*) counter to 2 if current value is 0" are idempotent.
It is quite weak as a requirement for example an API that functionally must not be cached can still be idempotent.
All "idempotent" actually means is that successive identical requests must induce the same change in the server's state due to the request itself. In the case of verbs like GET and QUERY, that is trivially true since they induce no change in the server's state at all. But the content of the response can of course change due to other events happening on the server. If "idempotent" required that not to happen, no request could ever be guaranteed to be idempotent.
Have you heard about visit counters? ;)
I would rather have a method that _may_ have side-effect on the server-side, but it's actually idempotent from the client-side (as in, truly reproducible results). That already exists in the form of a PUT + some content addressing scheme, for example, but it's open to each implementation.
Safe requests (all of which are necessarily also idempotent) are not reliably reproducible; GET of the same resource changes if there are server-state changes induced by other requests between GETs.
So, what you suggest is not failing to follow the spec.
RFC 2616 has already been obsoleted, and there is a draft (I think on its 19th draft or more) RFC obsoleting the set that obsoleted RFC 2616.
> to extend the GET method to allow request bodies.
Adding a new method is safer than changing the semantics of an existing one, “has a body” is a pretty major distinction for an HTTP message, whether a request method or response status.
After spending pages telling the reader that the query should not affect the server's state, the only example given appears to do exactly that: initiate a query and return a GET url to retrieve the results.
Either the GET request actually triggers the database request, which makes the QUERY request totally redundant, or the QUERY request relays a call to a database interpreter and the server responds with a location to retrieve the results.
Second, how would the http server know that the query is both idempotent and safe? Providing an example with SQL-like code makes it look even more like a bad joke...
I see this creates (at least) two problems and solves none. Do the authors know which problem they hope to solve?
If I had more time I'd look into their bios. Something tells me this is a typical case of "I put my name in a RFC", unless they work under the umbrella of some GAFAM who needs a new HTPP verb without disclosing why.
1: https://stackoverflow.com/questions/978061/http-get-with-req...
Method = "OPTIONS"
| "GET"
| "HEAD"
| "POST"
| "PUT"
| "DELETE"
| "TRACE"
| "CONNECT"
| extension-method
extension-method = token
"The list of methods allowed by a resource can be specified in an Allow header field (section 14.7). The return code of the response always notifies the client whether a method is currently allowed on a resource, since the set of allowed methods can change dynamically. An origin server SHOULD return the status code 405 (Method Not Allowed) if the method is known by the origin server but not allowed for the requested resource, and 501 (Not Implemented) if the method is unrecognized or not implemented by the origin server. The methods GET and HEAD MUST be supported by all general-purpose servers. All other methods are OPTIONAL."[1] https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5....
The long version:
RFC 7231 defines the standard HTTP methods in section 4.1. [1] Looking at it, the only methods that are required are GET and HEAD. All others are optional, and the spec explicitly calls out that additional methods may be created and registered with the IANA.
Looking closely at this RFC reveals two things:
1. It doesn't modify any of the HTTP RFCs. (There's no "Obsoletes" or "Updates" header.)
2. In section 6 of the QUERY RFC, it requests that the IANA add the new method to its registry. That follows the guidelines in RFC 7231 section 4.1.
[1] https://datatracker.ietf.org/doc/html/rfc7231#section-4.1
I chose Query.java as the class name for my combined GET/POST container back in 2008:
https://github.com/tinspin/rupy/blob/master/src/se/rupy/http...
Back then it was hosted on google code.
I like short names and make computer games, Zelda (or maybe just me) misspelled rupie rupy.
I did not know about Ruby Python back then... now I feel it's too late... eventually I'll try and change the name to binarytask since I bought binarytask.com...
QUERY /contacts HTTP/1.1 Host: example.org Content-Type: example/query Accept: text/csv
select surname, givenname, email limit 10 offset 40 key 2eQ8m5
May take a while, before it is supported enough, in many APIs.