Buy commercial curl support. We
help you work out your issues, debug your libcurl applications, use the API,
port to new platforms, add new features and more. With a team lead by the
curl founder Daniel himself.
On QUERY and -X
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Daniel Stenberg via curl-users <curl-users_at_lists.haxx.se>
Date: Tue, 25 Feb 2025 11:20:06 +0100 (CET)
Hello friends,
There is this proposal for a new HTTP method in the works called QUERY - "a
safe, idempotent request method that can carry request content" [1].
From a curl point of view it is just a version of POST.
We can make curl use this already today with something like:
curl -d moo -X QUERY https://example.com/
This however has some drawbacks if the site redirecs curl to somewhere else,
because if we also ask curl to follow them with:
curl -L -d moo -X QUERY https://example.com/
We run into problems with the -X and -L combination: the method set with -X is
used *unconditionally* in subsequent requests, while in HTTP lingo the
response code carrying the redirect includes a hint on how the subsequent
request should be done.
This is a current limitation in libcurl. My plan is to offer a new option [2]
there to rather make libcurl follow the status code in the following requests.
This new functionality that opens up the opportunity to make curl do QUERY
better by using this new flag. But how?
1. We change -X to use this new bit, and introduce new option for the
old behavior. This would have the benefit that it would automatically fix
all those thousands of scripts still use -X wrongly. It has the downside
that those you use -X "correctly" and rely on that behavior will break.
2. We add a new option that replaces -X as it might be an easier message to
keep "-X is probably not what you want" as a message. We could entertain
the idea of using -W for this (and a long version too of course).
3. We add a new option that replaces -L, but that means that the -X method
only gets used in redirects if the HTTP status code says so (307 or 308
basically). Again, we can use -W for this. Or maybe "-/" or something
similarly "crazy", if we rather keep the last alphabet letter for something
better in the future.
4. Another way?
[1] =
https://www.ietf.org/archive/id/draft-ietf-httpbis-safe-method-w-body-08.html
[2] = https://github.com/curl/curl/pull/16473
Date: Tue, 25 Feb 2025 11:20:06 +0100 (CET)
Hello friends,
There is this proposal for a new HTTP method in the works called QUERY - "a
safe, idempotent request method that can carry request content" [1].
From a curl point of view it is just a version of POST.
We can make curl use this already today with something like:
curl -d moo -X QUERY https://example.com/
This however has some drawbacks if the site redirecs curl to somewhere else,
because if we also ask curl to follow them with:
curl -L -d moo -X QUERY https://example.com/
We run into problems with the -X and -L combination: the method set with -X is
used *unconditionally* in subsequent requests, while in HTTP lingo the
response code carrying the redirect includes a hint on how the subsequent
request should be done.
This is a current limitation in libcurl. My plan is to offer a new option [2]
there to rather make libcurl follow the status code in the following requests.
This new functionality that opens up the opportunity to make curl do QUERY
better by using this new flag. But how?
1. We change -X to use this new bit, and introduce new option for the
old behavior. This would have the benefit that it would automatically fix
all those thousands of scripts still use -X wrongly. It has the downside
that those you use -X "correctly" and rely on that behavior will break.
2. We add a new option that replaces -X as it might be an easier message to
keep "-X is probably not what you want" as a message. We could entertain
the idea of using -W for this (and a long version too of course).
3. We add a new option that replaces -L, but that means that the -X method
only gets used in redirects if the HTTP status code says so (307 or 308
basically). Again, we can use -W for this. Or maybe "-/" or something
similarly "crazy", if we rather keep the last alphabet letter for something
better in the future.
4. Another way?
[1] =
https://www.ietf.org/archive/id/draft-ietf-httpbis-safe-method-w-body-08.html
[2] = https://github.com/curl/curl/pull/16473
-- / daniel.haxx.se || https://rock-solid.curl.dev -- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2025-02-25