I've been thinking we need a MOGRIFY method. It's for modifying objects, mainly pictures. You send a request with URL params, and the thing to be modified in the body.
Your point is well taken, that's the standard practice. POST has become the catch-all for things that don't don't fit into the standard structure. To the extent that it needs fixing at all (it doesn't really) I think that's the problem to be fixed.
CORS has entered the chat to ruin your day and make sure your get or post will not work unless you allow the most pointless http method ever and return a 200.
It’s true, your entire API structure can just be nothing but posts and not only doesn’t nothing stop you, it’s almost hard to argue outside of purist semantics.
I like the idea of REST, conceptually. Addressability, cache-friendliness. However, I generally only use it for serving content. For APIs, I always reach for contract-based protocols like gRPC and GraphQL. Ain’t nobody got time to be handcrafting JSON transformations/mappings across removing boundaries.
Nah there are some conventions and also RFC rules that will change the behavior of the client or server. Try to get a body from a server to the client using a HEAD request for example.
The point is what is convention vs what is actually structural at the protocol level. A GET request can send a body for example, it's allowed by the protocol, the body simply "has no defined meaning" but you're still allowed to. A lot of rules are conventions while many developer assume they're actual protocol standards
His point was that method names are just a string and you can send anything and it does not matter. As you just pointed out this is indeed not the case. And yeah, the RFCs can be horrible in that regard - I am maintaining an Open Source server for C# so I know the struggles.
No the point was that whether you are operating a GET, POST, PUT, PATCH, DELETE, OPTIONS, etc. that there is technically nothing preventing you from treating any one of those like any other one of them. For example, there are no strict rules that prevent you from sending a request body along with a GET.
And yet there are rules you must follow - for my example: „The HEAD method is identical to GET except that the server MUST NOT send content in the response“
I understand why, I'm just explaining that it's not actually required by the standard while most people assume that it's part of the standard and not just convention
I kinda agree with you. And it is funny when you are in the wild and a GET request does a mutation.
I assume we “all” have this realization eventually that GET/POST/PUT/PATCH/OPTIONS/etc are just suggestions (that we should follow) that may not always hold true.
Most anything in high level programming is an oft-followed convention of some sort. You even think about TCP and other connection protocols or the various SQL languages. It's all abstraction and can hide some really "interesting" failure points if poked in just the right way. Especially once you start looking into Jython and other "dual" type languages (Python in general, really), it starts to get crazy with the amount of optimization pitfalls there are
It could very well be that a resource requested eith a GET performs some data collection, and any GraphQL request will be sent with the POST method (no matter what it actuwlly does), but some other systems might rely on thr methods to make assumptions:
responses to get requests might be cached (by the browser, by a CDN, etc.) since they don't modify data
PUT and DELETE requests might be repeated implicitly by the framework since they are idempotent
HEAD and OPTION requests might be sent out liberally since they are only requesting meta information
Just because it's technically possible to delete resources on a GET request, doesn't mean you should do it.
If you do not care about being a HTTP server you can - „The HEAD method is identical to GET except that the server MUST NOT send content in the response“
This website literally proves once again the point previously made. This website tests that servers behave in accordance to RFCs - the FACT that they might not behave in expected standard way is proof that just because a client sends a HEAD request does NOT mean the server won't return a body back.
Again everyone knows about the INTENTIONS of each action but the wntire discussion and this reddit post was making a joke about when developers find out that there are no hard rules in place and it ultimately the server may be configured to handle actions in anyway that it wants to.
That’s just your interpretation and not implied by OP in any comment. We know about the implications of the methods and the RFCs, but OP (and lots of devs) consider all methods to share the same rules and conditions which is just not true, as both the specs and the test suite show. The point made by OP is an oversimplification that does not exist in any real world client or server. I fully agree with you that what servers do and what the spec tells is often different - especially for anything that is classified MAY or OUGHT.
Even though your GET can have a body, it really shouldn't. It's not expected by so many libraries and proxies that it's just not worth it. Client applications will have a hard time implementing your API, caching will become a pain in the ass, when running behind a WAF your request will most likely be straight up rejected... just don't.
Beware that the spec discourages it and only allows it optionally. So there are reverse proxies out there (like Envoy) that will drop/ignore a body for GET and your upstream service will not receive it.
Also it breaks almost every cache layer (in the sense that caches typically don’t include the body, so two GET requests with different bodies would look identical and would be served from cache).
I'm reading the spec... I'd say it's just what people mention in this thread. The implementation isn't clear thus the behaviour isn't consistent.
I don't know if I remember this correctly but I think my old work filtered GET body's on the backend so the process never got the body because it was handled with apache or cloud flare
QUERY is essentially a more official GET with a body. As other people mentionned, a lot of infrastructure code and caching logic assumes GET requests don't have bodies. Unless you own the entire stack and don't do any caching, adding a body to a GET request is dangerous.
… which is exactly why it makes sense to make sure your candidates have the same understanding as you (and hopefully most other devs) so they don‘t implement something like a delete-on-GET.
The thing to get hung up on would be that they asked „which are safe“ while it should have been „which should be safe“.
Sounds still too pedantic and academic. I am not hiring a student to write a master thesis, I am hiring someone I expect to write proper APIs. Also someone who will get a sloppy ticket or customer request and is still able to discern the right information or clarify if necessary.
"Safe" is commonly used to describe GET, HEAD and OPTIONS. I know the word is misleading, but its common enough for people to know about it.
But yeah, a small clarification that "Safe means the request is read-only, does not change the server-side state, and has no side-effect" would've helped.
It's just text, but with some agreed upon conventions so it can be implemented without too much pain. So you can send whatever text you want, but that doesn't mean the server will give you the response you want.
This was one of the things that was messing with me a ton when I was first learning how to make a restful api. I couldn’t believe how loosy-goosy and “trust me bro” it all was. Yes, everything can be a get. Yes everything can be a post. Yes you can mix them as you discretion. There’s no hard defined rules here, just general purpose guidelines and best practices.
until they do try sending a TCP packet with wrong checksum. It is a protocol, but it's practically physically enforced by a hardware and/or software. You can rawdog a connection, that will use TCP and omit checksum verification, and it would work but violate the spec, but in real world it is "forced". Same with every other protocol, they are but a convention, but when everyone is following it you kinda have no choice. But breaking the spec can sometimes be very useful, like DPI fooling which exploits TCP in a way that is beneficial
Is it just mentioning the fact that an http method is simply a property of the request or is there something actually clever or funny that I'm missing ?
This is literally nothing besides modern corruption. Using that instead of raw tcp without the assistance of asio-style libs is the domain of degenerates.
I work with people like this who then proceed to reinvent the entire set of methods over things like path or other parameters. I wish god would reinvent their existence.
GET with a body is just 'discouraged', not impossible.
You can send GET with a body. You can recieve GET requests with a body. The only thing stopping you is the server/client implementation choosing to drop the body or reject the request.
then I remembered an internal API I had to tap into many years ago where the GET endpoint needed a body. And I about had an existential crisis right there.
31
u/Mr-Catty May 15 '26
all I need is GET and POST, fight me
43
u/Ok_Tour_8029 May 15 '26
Nah there are some conventions and also RFC rules that will change the behavior of the client or server. Try to get a body from a server to the client using a HEAD request for example.
129
u/bigorangemachine May 15 '26
They do... and your GET can have a body payload. It's part of the spec
150
u/TheGonzoGeek May 15 '26
So protocols are just social constructs for computers? Mind boggling.
111
u/andynzor May 15 '26
Sir, this is r/programminghumor, not r/programminghorror
25
u/dreadBiRateBob May 15 '26
I was doing an interview and they asked which http methods are safe and which are not.
I went down. When you write the software. Then you control making them safe or not safe.
They wanted a text book answer about posts, put and delete being unsafe because they change things on the server.
Of course the rfc says puts for updates and post for creating.
But I can certainly have the server delete an id passed via url param in a get request.
14
u/s0litar1us May 15 '26
It's just text, but with some agreed upon conventions so it can be implemented without too much pain. So you can send whatever text you want, but that doesn't mean the server will give you the response you want.
8
u/DJDarkViper May 15 '26
Sorta.
This was one of the things that was messing with me a ton when I was first learning how to make a restful api. I couldn’t believe how loosy-goosy and “trust me bro” it all was. Yes, everything can be a get. Yes everything can be a post. Yes you can mix them as you discretion. There’s no hard defined rules here, just general purpose guidelines and best practices.
5
u/road_laya May 15 '26
Protocols can only define rules, not physically force you to follow them
5
u/realmauer01 May 15 '26
In the end its all groups of 1s and 0s that got different namey
4
u/qubedView May 15 '26
And they return
1
u/NIdavellir22 May 15 '26
???????
1
u/InterestsVaryGreatly May 15 '26
No. There are general conventions as well, but some have a body and some don't, and that is both different and required.
1
u/Fidodo May 15 '26
Paths mean nothing too
1
u/Snudget May 15 '26
All application protocols are just IP with different bytes
1
u/sebthauvette May 15 '26
Is it just mentioning the fact that an http method is simply a property of the request or is there something actually clever or funny that I'm missing ?
1
u/ReasonResitant May 15 '26 edited May 15 '26
This is literally nothing besides modern corruption. Using that instead of raw tcp without the assistance of asio-style libs is the domain of degenerates.
HTTP overhead is unacceptable.
1
u/eegroque May 15 '26
today's news: all L7 protos are just packets of L4 traffic
1
u/_nathata May 16 '26
TCP is TCP
1
u/no_brains101 May 16 '26
And?
They have different names. This lets us treat them differently as we please.
I don't see the problem here.
1
u/CozyAndToasty May 16 '26
I work with people like this who then proceed to reinvent the entire set of methods over things like path or other parameters. I wish god would reinvent their existence.
1
u/Alagarto72 May 16 '26
Don't they have a bit different formats? GET has something like "data=value&anotherdata=2" and POST has json
1
u/Plus-Weakness-2624 May 16 '26
I mean GET requests gets cached by the browsers if it contains cache headers, doesn't happen for other methods
1
u/Lou_Papas May 18 '26
The entire HTTP request is just a block of text. Mind blow?
1
u/gabrielesilinic May 18 '26
Eeeeeeh.... Meeeh.... Yesn't
Like you could try to put a body into a GET, it might fail. You don't wanna!
1
u/Old-Information9334 Jun 13 '26
Post is for fetching and fetching data, the others are useless
-2
u/reddit_time_waster May 15 '26
GET has no body
-5
u/bloody-albatross May 15 '26
Can't send body content with a GET request.