3 ms·
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 ignor
by EnnEmmEss 3mo ago
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 https://github.com/whatwg/fetch/issues/551
- nesarkvechnep 3mo agoThere's no such thing as REST spec. The closes mechanism to actual REST is to create a resource using POST and then query it using GET. You have the added benefit of the resource being cacheable.
- darig 3mo ago[dead]
- EnnEmmEss 3mo agoTo clarify, by REST spec I meant the state of access defined by https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Methods https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/....
- nesarkvechnep 3mo agoThis is just HTTP. The definitive guide to REST is "Architectural Styles and the Design of Network-based Software Architectures" by Roy Fielding.
- krackers 3mo ago>Additionally, a lot of existing web servers by default ignore GET requests with a body. I think the point made is that _all_ existing web servers have no idea what a "QUERY" is anyway, so changes need to be made anyhow.
- EnnEmmEss 3mo agoNot exactly. OPTIONS lets servers tell you that QUERY is supported if the client requests it and Status Code 405 lets servers tell you that QUERY is not supported. That's very different from the current landscape where several proxy servers and web servers simply ignore the Body of a GET request.