Live data from Hacker News

Defining a new HTTP method: HTTP Search (2021)

httptoolkit.com

111–120 of 131 posts

Re: Defining a new HTTP method: HTTP Search (2021)

#111

One advantage of GET is I can just copy the URL and share it. The article makes no mention of that. While I love the proposal (apart from the name, I can see the SEARCH verb being used for something that's not search), they should also address the URL share-ablity aspect. Something like " rel="nofollow">https://google.com/search where query can be arbitrarily large (>2000 URL length restriction) and the browser is sm…

The proposal has changed the name to QUERY, just yesterday.

Re: Defining a new HTTP method: HTTP Search (2021)

#112
post #71

Earlier quoted context omitted.

So can POST. It's entirely redundant

Verbs specify safety/idempotency guarantees for API-blind middleware, as well as whether (if either applies) a body needs taken into account; POST is not idempotent, SEARCH/QUERY is safe, and therefore also idempotent, but differs from GET in that that guarantee is body-specific.

Might as well just say "ok now GET can have body" instead of all that noise

Re: Defining a new HTTP method: HTTP Search (2021)

#113

Earlier quoted context omitted.

SEARCH can have a request body. Many systems limit the length of the URL, so this is significant.

If I send a request body with GET, what modern systems would even have a problem with that? Is there some caching middleware somewhere that I've never heard of or just ignored that will screw it up? If there was a GET-with-body http verb I'd probably use it at one point or another, but I often wonder where plain GET would start blowing up if I just used it for that. Honestly, I think rest is a mess, and that everythi…

GET with a body is pretty useless because the standard doesn’t allow the body to affect the results. So, proxies, browsers, etc. are free to ignore the body when caching results.

Re: Defining a new HTTP method: HTTP Search (2021)

#114

Earlier quoted context omitted.

SEARCH can have a request body. Many systems limit the length of the URL, so this is significant.

If I send a request body with GET, what modern systems would even have a problem with that? Is there some caching middleware somewhere that I've never heard of or just ignored that will screw it up? If there was a GET-with-body http verb I'd probably use it at one point or another, but I often wonder where plain GET would start blowing up if I just used it for that. Honestly, I think rest is a mess, and that everythi…

even though most servers support it AFAIK, many clients don't. Many will even silently discard the body when sending a GET request.

Re: Defining a new HTTP method: HTTP Search (2021)

#115

One advantage of GET is I can just copy the URL and share it. The article makes no mention of that. While I love the proposal (apart from the name, I can see the SEARCH verb being used for something that's not search), they should also address the URL share-ablity aspect. Something like " rel="nofollow">https://google.com/search where query can be arbitrarily large (>2000 URL length restriction) and the browser is sm…

This is why the RFC suggests you redirect to a GET like /resource/queryABCD

Re: Defining a new HTTP method: HTTP Search (2021)

#116

Earlier quoted context omitted.

That's not as much as you might think. There's a reason elasticsearch accepts POST

But what exactly is the difference between POST and SEARCH? Both include the request parameters in the body, so they would be obscured from the user. Unless they aren't, in which case it is a matter of the choices made in the implementation. Is it implied idempotency and the lack of a confirmation dialog when the user reloads the page?

Cachability, perhaps. You cannot cache a post, but may be able to cache a search or query verb.

Re: Defining a new HTTP method: HTTP Search (2021)

#117
post #112

Earlier quoted context omitted.

Verbs specify safety/idempotency guarantees for API-blind middleware, as well as whether (if either applies) a body needs taken into account; POST is not idempotent, SEARCH/QUERY is safe, and therefore also idempotent, but differs from GET in that that guarantee is body-specific.

Might as well just say "ok now GET can have body" instead of all that noise

Won’t retroactively change things that support GET to support GET-with-body. A new verb makes it much more likely that anything that supports the verb supports the desired semantics.

(Of course, you could instead bump the HTTP version for support of GET-with-body, but given how HTTP/2 and HTTP/3 are defined in terms of HTTP/1.1, you’d need three new versions of HTTP for a change to core verb semantics. A new verb, again, is far simpler.)

Re: Defining a new HTTP method: HTTP Search (2021)

#118
post #57

This seems reasonable, but unlikely to happen. GET is already pretty much sufficient, especially given that clients generally support megabytes worth of query strings in these modern times. If we're doing this though, I'll cast my vote for naming it more semantically as QUERY, and forgoing whatever little WebDAV compatibility would be had otherwise.

I’ve, amazingly, managed to hit the arbitrary megabyte limit in real production software.

Same, that's configurable though, and 1mb sounds like nginx. It's a lot higher on many other web servers including Apache.

Re: Defining a new HTTP method: HTTP Search (2021)

#119
post #84
post #49

I’d like to see this (or something like it) ship. Right now the two most common alternatives are: 1) GET, but base64 encode a json payload as a query param. Main downsides are that you can hit URL size limits, it makes the client and server slightly more complex (base64 encode/decode), and it sucks with browser dev tools - can’t nicely inspect the request in the browser, have to copy and decode it 2) Use POST to sear…

I would say that people should be more open to using HTTP in non-REST ways. Sometimes you want to send a request and receive a response, with arbirtrary restrictions and side effects that suit your cases. There are a lot of good reason for rest to exists, but also sometime you want to POST /open-garage-door?t=5-minutes and call it a day

Sure, the odd RPC style HTTP call is fine - not everything is cleanly modelled as a resource. But the lack of a clean way to make GET requests with a more complex request payload is simply a wart/shortcoming in the HTTP protocol IMO, and one that’s very correctable. Sucks to have to abandon RESTfulness even when I have a very “clean fit for the resource model” call to make, but the request body is too complex/large for HTTP query params.

Re: Defining a new HTTP method: HTTP Search (2021)

#120
Maybe read only query getting larger than the GET length limit indicates it's post-processing the object for you and not a "cachable" resource from a key value retrieval perspective? I.e your POST'ing a read only query since an application has to process the query for your at that point ?
Post reply on HN