5 ms·
I see the need, and good write up, but just use this for the definition of GET body. Nothing in the existing spec prevents GET from having a body, though there
by paulddraper 3y ago
I see the need, and good write up, but just use this for the definition of GET body.
Nothing in the existing spec prevents GET from having a body, though there isn't currently a semantic meaning to it.
This would fit perfectly, be more compatible and result in a simpler spec and protocol.
- rektide 3y agoWe'd have to change the behavior of browsers & server implementations to do this. Itvs much less risky, much more managable change, to do this with a new more deliberate difference. It'll make it clear that the new behavior is intended.
- paulddraper 3y ago> We'd have to change the behavior But you wouldn't for QUERY? This is backwards compatible and in many cases will just work since GET with body is already syntactically valid.
- janderland 3y agoI think they mean we’d have to modify existing features. There are probably assumptions made in code and tests around how GET will be used. Instead of breaking those assumptions and potentially implementing new bugs in an old feature, you can use a completely new HTTP method with completely new code paths. Older feature remains unchanged.
- rektide 3y agoQUERY is an explicit negotiating forwards. It would need support, but nothing with existing systems would change. No web page which accidentally tried to send a http bodied GET would start having new behavior.
- preseinger 3y agomiddleboxes are free to drop the body of a GET request, and many do
- treve 3y ago> But you wouldn't for QUERY? No, any good HTTP client or server allows unknown/new HTTP methods. If they are not recognized, they are treated as POST. This is a requirement of the HTTP spec. I've already used QUERY in a few places, and it basically universally just works. Adding a request body to GET would practically be much harder to deploy and depend on. A few years ago PATCH was added, and back then there was a bit more friction with some HTTP implementations only allowing a fixed set of methods, but this is mostly not true anymore.
- chromoblob 3y ago> If they are not recognized, they are treated as POST. This is a requirement of the HTTP spec. That's not true. "An origin server SHOULD return the status code ... 501 (Not Implemented) if the method is unrecognized or not implemented by the origin server." https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.1 https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5....
- treve 3y agoWhen you use a framework, and add a route that uses QUERY you 'implement' it. My point is that when you do, it will all just work.
- cientifico 3y agoCaching the body scares the hell out of me. If the params for the search are so many or so big that they don't fit in a single url, how could you use that as a cache key? Right now you can: * Pass the arguments as parameters * Pass them on the request body. I personally done it on apis for games in unity/ios/android for almost a decade). Other products like Elasticsearch count on that as part of the core product. * Semantically create searches in the server with POST /search In the previous two examples, you can return a redirect to the search results (like /searches/33) with perfect caching/indexing, and delegate to the server the cache algorithms. With things like Vary, Etags, Conditional fetchs, Content-Encoding, Content-Type, Cache-Control, Expires that the spec barely grasp, adding a huge body is something that a cache server/cdn will not implement. So again. What is this spec solving?
- thwarted 3y ago> If the params for the search are so many or so big that they don't fit in a single url, how could you use that as a cache key? The way many caching systems work, by hashing the body and using the hash as the cache key.
- ezekg 3y agoAbsolutely. I would not recommend using raw search terms as a cache key. Good way to a) leak cache data unintentionally if an attacker were to guess at other cache keys (given the cache keys were not namespaced well), and b) leak user search terms (and users often search for some weird stuff including passwords).
- franga2000 3y agoa) Unless you're caching only a single endpoint, which you almost never are, you'd need to have the URL or at least path be a part of the key too, so that solves the "stealing cache from another app/component" (also not having any namespacing is a bad idea regardless, even if using hashes) b) Unless your cache keys are publicly listable, this is not a security issue. And from a privacy perspective, GET requests are usually cached by path+params, and since search queries are usually in params these days, again, nothing changes. That's not to say you shouldn't use cryptographic hash functions for keys, just that nothing really changes with this new verb.
- lozenge 3y agoDespite the spec, a lot of clients, load balancers, and server libraries can't handle GET with a body.
- silverwind 3y agoThey won't support a new method either.
- derefr 3y agoBut it being an unsupported method will hopefully at least cause the middlebox to generate a 405 error, rather than undefined behavior.
- bruce511 3y agoWhich is somewhat surprising given that it is common enough that I've come across it several times in the wild. So much so that I added support for it to my own server and client libraries. Which means that adding support for QUERY will be trivial (yay!) As an aside, I also support DELETE with a body.
- sarthak-ag 3y agoYet, given enough demand, and a explicit recommending nod from the spec, these will comply. It's not really as big as problem as everyone seems to think. And it's literally the same amount of work of adding a new verb.