| ▲ | The new HTTP QUERY method explained(kreya.app) |
| 119 points by CommonGuy 4 hours ago | 57 comments |
| |
|
| ▲ | ramon156 an hour ago | parent | next [-] |
| "QUERY is just GET" "Using GET with a Body works" Seems like this is going everyone's head. You're not supposed to use GET with a Body, this is a hack, therefore having an explicit method makes sense. Just because it works, doesn't mean its the right way |
| |
| ▲ | EnnEmmEss 9 minutes ago | parent | next [-] | | Using GET with a Body doesn't work if you try using it in the browser with JS fetch for example[1]. Additionally, a lot of existing web servers by default ignore GET requests with a body. The use case of QUERY is because POST conveys non-safe, non-idempotent requests which can potentially modify stuff according to the REST spec. GET requests on the other hand convey retrieval of a resource. However, due to GET requests not having a body, there's a limit to the amount of data you can put in the URL and you also cannot put sensitive data in it. Additionally, GET requests are meant to be highly cacheable by default while a lot of the QUERY type requests are usually meant more for one-shot access. QUERY is meant to address these limitations. [1]: https://github.com/whatwg/fetch/issues/551 | |
| ▲ | ronbenton 34 minutes ago | parent | prev | next [-] | | I’ve seen a framework strip body content off GET requests, so doing hacky things doesn’t even always work. The QUERY method is a welcome addition | | |
| ▲ | pdpi 19 minutes ago | parent | next [-] | | Insofar as I'm concerned, a GET request with a body is an attack-shaped aberration. E.g. Somebody who's trying to get me to mix up validating query string parameters and request body parameters. Hacky things not working is a feature, not a bug. | |
| ▲ | psychoslave 17 minutes ago | parent | prev [-] | | Is the stripper service in question already implementing it? |
| |
| ▲ | cryo32 26 minutes ago | parent | prev | next [-] | | The whole stack is a pile of badly designed hacks. Not much point in fixing it now. I mean they can’t even spell referrer correctly. | |
| ▲ | dotancohen an hour ago | parent | prev [-] | | > Just because it works, doesn't mean its the right way
Tell that to anybody in the business long enough to decipher someone else's Perl! |
|
|
| ▲ | Asmod4n 17 minutes ago | parent | prev | next [-] |
| Slightly off topic Funfact: you can buy a several thousand dollars expensive ssl intercepting proxy appliance which doesn’t support anything beyond http/1.1. Will be fun when those see a whole new http verb, I bet that leads to at least DoS by the track record of that company. |
|
| ▲ | tosti 2 hours ago | parent | prev | next [-] |
| > using HTTP GET with a request body is a bad idea, as for example users behind a corporate firewall or a different browser may be unable to use your website. So is using QUERY requests for quite some time from now. |
| |
| ▲ | jy14898 2 hours ago | parent | next [-] | | 405 Method Not Allowed is trivial to fall back to POST. How do you know the GET request behaved incorrectly? | | |
| ▲ | tosti an hour ago | parent [-] | | That's assuming the corporate proxy is well-behaved. | | |
| ▲ | jagged-chisel 36 minutes ago | parent [-] | | Then all bets are off, and I guess we just can’t HTTP ever again because a proxy can misbehave. One should adhere to Best Practices since one cannot control every device between the app and the user. Best Practice says “GET has no body. QUERY can have a body. If QUERY fails (405), use POST with the body.” And eventually, enough proxies will behave well enough that at least the HTTP bit of the app has a chance of working. |
|
| |
| ▲ | jbverschoor 2 hours ago | parent | prev [-] | | Yeah, query seems just GET with a body. No difference in protocol nor behavior | | |
|
|
| ▲ | ktpsns 4 hours ago | parent | prev | next [-] |
| HTTP QUERY was discussed many times in the past here: https://news.ycombinator.com/item?id=48568502 (4d ago, 173 comments) https://news.ycombinator.com/item?id=29794838 (4y ago, 125 comments) |
|
| ▲ | 8-prime 2 hours ago | parent | prev | next [-] |
| It's interesting to see additions to HTTP methods as it much feels like the existing ones are set in stone. At least for the time that I have been a developer.
I'm curious to see how fast the adoption/support for HTTP QUERY will be. I've had my fair share of situations where I wished for something like HTTP QUERY. |
| |
| ▲ | PunchyHamster 2 hours ago | parent | next [-] | | zero. Many libs will/can just request method as a string so you can start coding now > I've had my fair share of situations where I wished for something like HTTP QUERY. Using POST instead comes with no drawbacks | | |
| ▲ | rezonant an hour ago | parent [-] | | I think the article summarizes pretty well what the drawbacks of POST are: unclear idempotency (well it's actually pretty damned clear: they are not cacheable). That complicates caching logic, and that's not just for the application server itself, but any reverse proxies in front of it as well as the user agent itself. I'm not sure QUERY is a great solution, because in the context of a web application absolutely no one enjoys using a page that does not keep its state on refresh, so that really limits where QUERY makes sense, but if you have a case that is not driven by navigation, great. |
| |
| ▲ | hparadiz 2 hours ago | parent | prev [-] | | I can implement it in about 10 minutes. Not even kidding. | | |
| ▲ | echoangle 2 hours ago | parent [-] | | In what role? As a user writing client code or when implementing the caching middleware or the Webserver? | | |
|
|
|
| ▲ | _alphageek 36 minutes ago | parent | prev | next [-] |
| >> QUERY request can be cached I have a weird feeling. Query body is encrypted by https. So CDN will not be able to cache results.
In order to make it work right - whole topology of the internet should be redone. Caching on the backend server will not give any real gains for large scale apps. |
| |
| ▲ | CodesInChaos 30 minutes ago | parent [-] | | The whole connection is encrypted by https, the request body is treated the same as the url, the headers or the response. The only unencrypted parts are the IP addresses/ports and the domain name (if SNI without ECH is used). CDNs already terminate TLS connections so they can cache GET requests. |
|
|
| ▲ | mi_lk 20 minutes ago | parent | prev | next [-] |
| OK, but stop trying to make fetch happen. |
|
| ▲ | waweic 2 hours ago | parent | prev | next [-] |
| I wonder what the drawbacks of standardizing a GET body would have been. CoAP already has it (which creates friction in building CoAP<->HTTP proxies). All in all, I dislike the overall focus on the HTTP method when designing "RESTful" interfaces. If all we're building is, effectively, an RPC, why would the cacheability meta-information be the first thing we specify? |
| |
| ▲ | braiamp 32 minutes ago | parent [-] | | A absolute swats of middle boxes that will not get addressed ever. As industry, it's preferable to create something that is a hard break and makes players upgrade and give people a feature to argue for said upgrade |
|
|
| ▲ | doctor_phil 2 hours ago | parent | prev | next [-] |
| Nice, not having bodies on GET has been a pet peeve of mine for a long time. It would be nice to allow bodies on DELETE as well, but that is less of a problem in most cases. |
|
| ▲ | koolala 3 hours ago | parent | prev | next [-] |
| What do you think people will make the Query request body? Most everything will use this for JSON but it could be anything so what other interesting things do you think will go in there? Query 1 + 1 and get 2? |
| |
| ▲ | pmontra 9 minutes ago | parent | next [-] | | We might start using QUERY for the search requests from our web app to our server, if nothing in the stack in between the app and our server side code does not drop the body. A JSON body beats the spaghetti arguments of most filters. | |
| ▲ | miggol 2 hours ago | parent | prev | next [-] | | Considering the guideline that QUERY should be idempotent and cacheable, file querying requests come to mind. Reverse image search, for example. | |
| ▲ | CommonGuy 40 minutes ago | parent | prev | next [-] | | GraphQL implementations could switch to this | |
| ▲ | dreambigwrkhard 2 hours ago | parent | prev [-] | | I'm curious too. Unless the developer is really passionate about this I don't think a dev will risk (potential) compatibility issues or unexpected footguns to use this when the workarounds do seem to work quite well already. I just dont see the benefit but maybe it's because I am just not aware of a real world use case; happy to be corrected. | | |
| ▲ | unilynx 2 hours ago | parent [-] | | Elastic/Opensearch uses GET requests with a body for search, which is complicated or forbidden (not exactly sure) with the HTTP spec. Not all HTTP clients are willing to submit a body with a GET. So opensearch also allows you to POST search requests, but those are uncacheable QUERY would fit here perfectly - it's probably trivial for opensearch to add but it will take some time for clients to catch up. |
|
|
|
| ▲ | Rapzid an hour ago | parent | prev | next [-] |
| Body is already optional with GET. Proxies aren't supposed to touch it or assign meaning to it; it's between the client and the end server. A whole new method whose semantics don't really fit with the others is.. An odd way forward. |
| |
| ▲ | CommonGuy an hour ago | parent | next [-] | | Proxies are allowed to drop bodies of HTTP GET requests. RFC 9110 states: > [..] content received in a GET request has no generally defined semantics, cannot alter the meaning or target of the request [..] > A client SHOULD NOT generate content in a GET request [..] | | | |
| ▲ | juliangmp an hour ago | parent | prev | next [-] | | Yeah I always disliked that there's this idea that you can't put a body on a GET request.
Iirc openapi generators goes out of its way to not support that which has lead to me writing a small rant into an API specification before to explain why the get_xyz uses POST... | |
| ▲ | thewisenerd an hour ago | parent | prev [-] | | semantics become extremely relevant when "proxies" start caching. |
|
|
| ▲ | IshKebab 43 minutes ago | parent | prev | next [-] |
| What are the chances sites start using this to prevent sharing links... |
|
| ▲ | restful2 36 minutes ago | parent | prev | next [-] |
| This breaks rest/crud. |
| |
|
| ▲ | johnnyevert 26 minutes ago | parent | prev | next [-] |
| Will this be compatible with graphql? |
|
| ▲ | grugdev42 2 hours ago | parent | prev | next [-] |
| We should have just added optional body support for GET requests. So much simpler... |
| |
|
| ▲ | xxkcd 33 minutes ago | parent | prev | next [-] |
| Don’t add new stuff (query). Instead fix the broken shit that’s already added (get). Sigh. Xkcd standards. |
|
| ▲ | marc_vuit an hour ago | parent | prev | next [-] |
| nice man |
|
| ▲ | nokeya 2 hours ago | parent | prev [-] |
| If it needs so much explanation and discussion, maybe it is not a great idea after all? |
| |
| ▲ | flyingshelf an hour ago | parent | next [-] | | Arguably the only explanation you need is that "QUERY is the same as GET plus a body". The article just explains what GET is and isn't, but that can be implied. | |
| ▲ | reddalo 2 hours ago | parent | prev | next [-] | | The article describes the current situation first. The whole explanation is quite simple: QUERY requests are the same as GET, but they have a body. | | |
| ▲ | someguynamedq 2 hours ago | parent [-] | | So just add an optional body to get | | |
| ▲ | dxdm 18 minutes ago | parent [-] | | The article also addresses why this is not the chosen solution. It's pretty much the first one you'd think of: all kinds of existing software (that can be between client and server and out of their control) already handle GET bodies in all kinds of incompatible ways, because the existing standard says they're meaningless and "shouldn't" be included. The idea is to not break people's stuff, so they don't rugpull the established standard. There's usually a reason why the simplest solution that pops into one's head is not "just" used by the people who put a lot more thought into it. Not always, but it can be useful to try to come up with it. |
|
| |
| ▲ | IshKebab 44 minutes ago | parent | prev [-] | | It doesn't really need that much explanation though. TL;DR: It's GET but with bodies officially supported. |
|