Closed vszakats closed 2 months ago
Maybe, instead of this, there could be a set-if-not-set syntax e.g. ?=
(since :=
is already used); then you could use -s 'port?=1234'
etc too
I started working on @emanuele6's proposal only to run into a minor issue:
When we parse a URL without a scheme, we must ask libcurl to guess the scheme because otherwise it does not accept the URL. When it guesses a scheme, it sets that for the URL and when we subsequently check the URL we can no longer figure out if the scheme is the result of a guess or not.
Therefore, we can't after the fact replace the scheme if it was not previously set, because we no longer have the information if the scheme was guessed or not.
All other parts of the URL can be polled if it exists or not before setting it again, and I will soon make a PR for that change.
I have created https://github.com/curl/curl/pull/13616 for curl, to allow us to query the URL proper if the set scheme was guessed or set. But that will take a little while until it lands there.
CURLU_NO_GUESS_SCHEME
has been merged into curl's git and will ship in the pending curl 8.9.0 release.
For now the default scheme seems to be coming from libcurl, which is typically 'http'. It could be useful to override it to something else, such as 'https' to get secure-by-default URLs.
E.g. with
--default-scheme https
.trurl --url example.org → http://example.org/ trurl --url example.org --default-scheme https → https://example.org/