urlapi: provide more detailed return codes

Previously, the return code CURLUE_MALFORMED_INPUT was used for almost
30 different URL format violations. This made it hard for users to
understand why a particular URL was not acceptable. Since the API cannot
point out a specific position within the URL for the problem, this now
instead introduces a number of additional and more fine-grained error
codes to allow the API to return more exactly in what "part" or section
of the URL a problem was detected.

Also bug-fixes curl_url_get() with CURLUPART_ZONEID, which previously
returned CURLUE_OK even if no zoneid existed.

Test cases in 1560 have been adjusted and extended. Tests 1538 and 1559
have been updated.

Updated libcurl-errors.3 and curl_url_strerror() accordingly.

Closes #8049
This commit is contained in:
Daniel Stenberg 2021-11-23 17:07:31 +01:00
parent a5f5687368
commit 4183b8fe9a
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
8 changed files with 289 additions and 111 deletions

View file

@ -20,7 +20,7 @@
.\" *
.\" **************************************************************************
.\"
.TH libcurl-errors 3 "1 Jan 2010" "libcurl 7.20.0" "libcurl errors"
.TH libcurl-errors 3 "23 Nov 2021" "libcurl 7.81.0" "libcurl errors"
.SH NAME
libcurl-errors \- error codes in libcurl
.SH DESCRIPTION
@ -361,6 +361,30 @@ There is no port part in the URL.
There is no query part in the URL.
.IP "CURLUE_NO_FRAGMENT (17)"
There is no fragment part in the URL.
.IP "CURLUE_NO_ZONEID (18)"
There is no zoneid set in the URL.
.IP "CURLUE_BAD_FILE_URL (19)"
The file:// URL is invalid.
.IP "CURLUE_BAD_FRAGMENT (20)"
The fragment part of the URL contained bad or invalid characters.
.IP "CURLUE_BAD_HOSTNAME (21)"
The hostname contained bad or invalid characters.
.IP "CURLUE_BAD_IPV6 (22)"
The IPv6 address hostname contained bad or invalid characters.
.IP "CURLUE_BAD_LOGIN (23)"
The login part of the URL contained bad or invalid characters.
.IP "CURLUE_BAD_PASSWORD (24)"
The password part of the URL contained bad or invalid characters.
.IP "CURLUE_BAD_PATH (25)"
The path part of the URL contained bad or invalid characters.
.IP "CURLUE_BAD_QUERY (26)"
The query part of the URL contained bad or invalid characters.
.IP "CURLUE_BAD_SCHEME (27)"
The scheme part of the URL contained bad or invalid characters.
.IP "CURLUE_BAD_SLASHES (28)"
The URL contained an invalid number of slashes.
.IP "CURLUE_BAD_USER (29)"
The user part of the URL contained bad or invalid characters.
.SH "SEE ALSO"
.BR curl_easy_strerror "(3), " curl_multi_strerror "(3), "
.BR curl_share_strerror "(3), " curl_url_strerror "(3), "

View file

@ -838,9 +838,20 @@ CURLSSLSET_UNKNOWN_BACKEND 7.56.0
CURLSTS_DONE 7.74.0
CURLSTS_FAIL 7.74.0
CURLSTS_OK 7.74.0
CURLUE_BAD_FILE_URL 7.81.0
CURLUE_BAD_FRAGMENT 7.81.0
CURLUE_BAD_HANDLE 7.62.0
CURLUE_BAD_HOSTNAME 7.81.0
CURLUE_BAD_IPV6 7.81.0
CURLUE_BAD_LOGIN 7.81.0
CURLUE_BAD_PARTPOINTER 7.62.0
CURLUE_BAD_PASSWORD 7.81.0
CURLUE_BAD_PATH 7.81.0
CURLUE_BAD_PORT_NUMBER 7.62.0
CURLUE_BAD_QUERY 7.81.0
CURLUE_BAD_SCHEME 7.81.0
CURLUE_BAD_SLASHES 7.81.0
CURLUE_BAD_USER 7.81.0
CURLUE_MALFORMED_INPUT 7.62.0
CURLUE_NO_FRAGMENT 7.62.0
CURLUE_NO_HOST 7.62.0
@ -850,6 +861,7 @@ CURLUE_NO_PORT 7.62.0
CURLUE_NO_QUERY 7.62.0
CURLUE_NO_SCHEME 7.62.0
CURLUE_NO_USER 7.62.0
CURLUE_NO_ZONEID 7.81.0
CURLUE_OK 7.62.0
CURLUE_OUT_OF_MEMORY 7.62.0
CURLUE_UNKNOWN_PART 7.62.0