urlapi: add CURLU_NO_GUESS_SCHEME

Used for extracting:

- when used asking for a scheme, it will return CURLUE_NO_SCHEME if the
  stored information was a guess

- when used asking for a URL, the URL is returned without a scheme, like
  when previously given to the URL parser when it was asked to guess

- as soon as the scheme is set explicitly, it is no longer internally
  marked as guessed

The idea being:

1. allow a user to figure out if a URL's scheme was set as a result of
  guessing

2. extract the URL without a guessed scheme

3. this makes it work similar to how we already deal with port numbers

Extend test 1560 to verify.

Closes #13616
This commit is contained in:
Daniel Stenberg 2024-06-01 12:03:34 +02:00
parent 80aa519545
commit 655d44d139
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 38 additions and 2 deletions

View file

@ -125,6 +125,22 @@ nothing following the hash sign.
(Added in curl 8.8.0)
## CURLU_NO_GUESS_SCHEME
When this flag is used in curl_url_get(), it treats the scheme as non-existing
if it was set as a result of a previous guess; when CURLU_GUESS_SCHEME was
used parsing a URL.
Using this flag when getting CURLUPART_SCHEME if the scheme was set as the
result of a guess makes curl_url_get() return CURLUE_NO_SCHEME.
Using this flag when getting CURLUPART_URL if the scheme was set as the result
of a guess makes curl_url_get() return the full URL without the scheme
component. Such a URL can then only be parsed with curl_url_set() if
CURLU_GUESS_SCHEME is used.
(Added in curl 8.9.0)
# PARTS
## CURLUPART_URL

View file

@ -1068,6 +1068,7 @@ CURLU_GET_EMPTY 8.8.0
CURLU_GUESS_SCHEME 7.62.0
CURLU_NO_AUTHORITY 7.67.0
CURLU_NO_DEFAULT_PORT 7.62.0
CURLU_NO_GUESS_SCHEME 8.9.0
CURLU_NON_SUPPORT_SCHEME 7.62.0
CURLU_PATH_AS_IS 7.62.0
CURLU_PUNY2IDN 8.3.0