8000 curl: add --location-mode keep/spec/init by bagder · Pull Request #16543 · curl/curl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

curl: add --location-mode keep/spec/init #16543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

8000 Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

bagder
Copy link
Member
@bagder bagder commented Mar 3, 2025

Sets the "mode" for how to treat and use a custom HTTP method when following redirects.

The idea being that a user can set location-mode: spec in their .curlrc or similar to get this functionality by default every time they use -L/--location.

Potential future command line to send QUERY and following a redirect according to the status code:

curl -d "request-body" -X QUERY --location-mode spec -L https://example.com 

@bagder bagder added cmdline tool feature-window A merge of this requires an open feature window labels Mar 3, 2025
@bagder bagder marked this pull request as ready for review March 3, 2025 13:47
@testclutch

This comment was marked as resolved.

@bagder

This comment was marked as resolved.

@bagder bagder changed the title curl: add --request-mode all/obey/first curl: add --location-mode all/obey/first Mar 3, 2025
@bagder bagder force-pushed the bagder/request-mode branch from 57b9e36 to 4e5fe66 Compare March 6, 2025 16:03
@bagder bagder force-pushed the bagder/request-mode branch from 4e5fe66 to 0bac12b Compare March 15, 2025 20:55
@divinity76
Copy link
Contributor

all, obey, first => keep, spec, initial?

@bagder
Copy link
Member Author
bagder commented Apr 25, 2025

all, obey, first => keep, spec, initial?

I like that! 👍

bagder added 3 commits April 25, 2025 13:09
Sets the "mode" for how to treat and use a custom HTTP method when
following redirects.
@bagder bagder force-pushed the bagder/request-mode branch from 0bac12b to f422d01 Compare April 25, 2025 11:20
@bagder bagder changed the title curl: add --location-mode all/obey/first curl: add --location-mode keep/spec/init Apr 25, 2025
@github-actions github-actions bot added the tests label Apr 25, 2025
@dboehmer
Copy link
dboehmer commented Apr 25, 2025

I’m still thinking about the naming of the parameter and its modes 🫤

This not so much about handling the Location header with the next address but about which request method to use for requests following 30[12378] response codes. But I see that existing curl options are named --location-*.

Currently the man page will read:

--location-mode <mode>

and as mode is no preexisting technical term (like --create-file-mode is for Unix modes for permissions) I think it’s redundant and one could come up with a more descriptive name. I suggest --location-method <mode>.

My two cents on the mode names then:

  • spec—really great and unambiguous 👍
  • init—I have some trouble with that because keep is drafted to mean “use method from initial request” and they could be easy to be mixed up. Thinking about my comment appending the doc saying that subsequent requests will all be GET could this simply be get?
  • keep—I think I also liked all a lot. I’d very much prefer to see a reference to “use method from initial request” but init is currently chosen for “set only for initial request”—this doesn’t match to the parameter name, though, which focuses on the subsequent “location” requests

@icing
Copy link
Contributor
icing commented Apr 25, 2025

I read --location-mode more as --follow-X with values spec|same|reset.

bagder and others added 2 commits April 28, 2025 08:10
Co-authored-by: Daniel Böhmer <post@daniel-boehmer.de>
Co-authored-by: Daniel Böhmer <post@daniel-boehmer.de>
@bagder
Copy link
Member Author
bagder commented Apr 28, 2025

Naming is hard!

@bagder
Copy link
Member Author
bagder commented Apr 29, 2025

To give us more time to think and discuss about the parameter naming, even on the option itself, we have decided to let this PR wait for the next feature window, presumably for 8.15.0 instead of 8.14.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmdline tool feature-window A merge of this requires an open feature window tests
Development

Successfully merging this pull request may close these issues.

5 participants
0