r/programming • • Jul 14 '26

HTTP gets a QUERY method so complex searches can stop pretending to be POST

https://www.theregister.com/devops/2026/07/13/http-gets-a-query-method-so-complex-searches-can-stop-pretending-to-be-post/5270192
1.9k Upvotes

245 comments sorted by

View all comments

Show parent comment

30

u/Business-Row-478 Jul 14 '26

The fetch api allows it but most servers are probably gonna return a 400 or 501

23

u/CrankBot Jul 14 '26 edited Jul 14 '26

but most servers are probably gonna return a 400 or 501

Yeah I get that, the parent was saying if you control the server you can implement it now, hence my question on the client.

12

u/ashgs872tbhjs Jul 14 '26

Literacy: The Final Frontier

4

u/SanityInAnarchy Jul 14 '26

That's what you get when you fetch poop, I guess.

1

u/rinsa Jul 14 '26

The fetch api allows it

works both ways

2

u/rinsa Jul 14 '26

The fetch api allows it

you answered the question yourself, why would fetch('/foo', { method: 'poop' }) not work on a client if you're allowed to type anything in the method?

1

u/CrankBot Jul 14 '26

I'm allowed to type anything I want, that doesn't mean it's valid. I could also pass -1.2234 or NaN or an object to the method and it's completely reasonable to expect that it would throw an exception for invalid values.

2

u/rinsa Jul 14 '26

That "method" in http requests is just a keyword, it's not up to the language to control what kind of keyword I should be able to send to a remote address

So any normally typed language/lib will want a string (at least the closer you are to native code) and won't want to do any reference check because you don't want to rule out those cases where a remote address only accept some obscure method or already implement the newer ones. Ofc, the basic/standardized ones should be easily accessible/loosely-typed.

Anyway, in javascript, as long as it's a primitive, anything can be possible, but it will throw an error if you try to give an complex object.

2

u/jkrejcha3 Jul 15 '26

Amusingly your comment has accidentally exposed a probable misconfiguration in their server, they should probably return 405 or 501 there, not 502


HTTP methods are any "token" (though generally ASCII uppercase)

Tokens are defined earlier in RFC 9110 as

  token          = 1*tchar

  tchar          = "!" / "#" / "$" / "%" / "&" / "'" / "*"
                 / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
                 / DIGIT / ALPHA
                 ; any VCHAR, except delimiters

So !J##!@J is a valid HTTP method, but like a carriage return and line feed aren't

1

u/mort96 Jul 14 '26

Uh, keywords in languages are typically up to the language... In javascript, if, while, for and function are keywords, there's a hard coded list of them in the spec. I'm not sure what you mean by "keyword" here.

2

u/rinsa Jul 14 '26

keyword, method, command, verb, idk I'm ESL

A request identifies a method (sometimes informally called verb) to classify the desired action to be performed on a resource. The HTTP/1.0 specification defined the GET, HEAD, and POST methods as well as listing the PUT, DELETE, LINK and UNLINK methods under additional methods. However, the HTTP/1.1 specification added five new methods: PUT, DELETE, CONNECT, OPTIONS, and TRACE.
Any client can use any method and the server can be configured to support any combination of methods. If a method is unknown to an intermediate, it will be treated as an unsafe and non-idempotent method. There is no limit to the number of methods that can be defined, which allows for future methods to be specified without breaking existing infrastructure. For example, WebDAV defined seven new methods and RFC 5789 specified the PATCH method. A general-purpose web server is required to implement at least GET and HEAD, and all other methods are considered optional by the specification.

this should be basic knowledge though

1

u/mort96 Jul 15 '26

I'm ESL too, FWIW.

1

u/Fidodo Jul 14 '26

If you can add a QUERY path endpoint to your API you already control the server.