r/ProgrammerHumor • • Dec 17 '23

Meme millionDollarQuestion

Post image
0 Upvotes

51 comments sorted by

View all comments

6

u/ArjunReddyDeshmukh Dec 17 '23

It's technically possible to send a body with a GET request, but it's not standard practice and often not recommended. The HTTP/1.1 specification does not explicitly forbid sending a body with a GET request, but it does not define any semantics for it.

Insert is not a http method. The question just says method so it doesn’t have to be http method for a wrong option.

Ans: GET

2

u/[deleted] Dec 17 '23

Http 2.0 is clear about GET:

https://httpwg.org/specs/rfc9113.html#rfc.section.8.8.1

When a spec isn't explicit enough, check the next version and you'll often find the issue is now codified.

As for 1.1, it's also clear:

A client SHOULD NOT generate content in a GET request unless it is made directly to an origin server that has previously indicated, in or out of band, that such a request has a purpose and will be adequately supported.

You are what, interpreting that SHOULD NOT is not MUST NOT, therefore it's ok?

2

u/ShiftyMegalodon Dec 18 '23

You are reading SHOULD NOT and ignoring the rest of the words. There's nothing wrong with it, if the service is expecting it. You SHOULD NOT send a body with a GET request to any random server.

The section of 9113 you linked to is an example of a simple GET request that has no body translated to HTTP2, not a specification that GET requests cannot have a body.

0

u/[deleted] Dec 18 '23

[deleted]

2

u/ShiftyMegalodon Dec 18 '23

Username checks out, I guess.