mirror of
https://github.com/curl/curl.git
synced 2026-08-25 14:13:34 +03:00
urlapi: add curl_url_strerror()
Add curl_url_strerror() to convert CURLUcode into readable string and facilitate easier troubleshooting in programs using URL API. Extend CURLUcode with CURLU_LAST for iteration in unit tests. Update man pages with a mention of new function. Update example code and tests with new functionality where it fits. Closes #7605
This commit is contained in:
parent
f0b8d1c5f6
commit
3363eeb262
25 changed files with 233 additions and 72 deletions
|
|
@ -453,6 +453,78 @@ curl_share_strerror(CURLSHcode error)
|
|||
#endif
|
||||
}
|
||||
|
||||
const char *
|
||||
curl_url_strerror(CURLUcode error)
|
||||
{
|
||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||
switch(error) {
|
||||
case CURLUE_OK:
|
||||
return "No error";
|
||||
|
||||
case CURLUE_BAD_HANDLE:
|
||||
return "An invalid CURLU pointer was passed as argument";
|
||||
|
||||
case CURLUE_BAD_PARTPOINTER:
|
||||
return "An invalid 'part' argument was passed as argument";
|
||||
|
||||
case CURLUE_MALFORMED_INPUT:
|
||||
return "A malformed input was passed to a URL API function";
|
||||
|
||||
case CURLUE_BAD_PORT_NUMBER:
|
||||
return "The port number was not a decimal number between 0 and 65535";
|
||||
|
||||
case CURLUE_UNSUPPORTED_SCHEME:
|
||||
return "This libcurl build doesn't support the given URL scheme";
|
||||
|
||||
case CURLUE_URLDECODE:
|
||||
return "URL decode error, most likely because of rubbish in the input";
|
||||
|
||||
case CURLUE_OUT_OF_MEMORY:
|
||||
return "A memory function failed";
|
||||
|
||||
case CURLUE_USER_NOT_ALLOWED:
|
||||
return "Credentials was passed in the URL when prohibited";
|
||||
|
||||
case CURLUE_UNKNOWN_PART:
|
||||
return "An unknown part ID was passed to a URL API function";
|
||||
|
||||
case CURLUE_NO_SCHEME:
|
||||
return "There is no scheme part in the URL";
|
||||
|
||||
case CURLUE_NO_USER:
|
||||
return "There is no user part in the URL";
|
||||
|
||||
case CURLUE_NO_PASSWORD:
|
||||
return "There is no password part in the URL";
|
||||
|
||||
case CURLUE_NO_OPTIONS:
|
||||
return "There is no options part in the URL";
|
||||
|
||||
case CURLUE_NO_HOST:
|
||||
return "There is no host part in the URL";
|
||||
|
||||
case CURLUE_NO_PORT:
|
||||
return "There is no port part in the URL";
|
||||
|
||||
case CURLUE_NO_QUERY:
|
||||
return "There is no query part in the URL";
|
||||
|
||||
case CURLUE_NO_FRAGMENT:
|
||||
return "There is no fragment part in the URL";
|
||||
|
||||
case CURLUE_LAST:
|
||||
break;
|
||||
}
|
||||
|
||||
return "CURLUcode unknown";
|
||||
#else
|
||||
if(error == CURLUE_OK)
|
||||
return "No error";
|
||||
else
|
||||
return "Error";
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
/* This is a helper function for Curl_strerror that converts Winsock error
|
||||
* codes (WSAGetLastError) to error messages.
|
||||
|
|
|
|||
|
|
@ -1954,7 +1954,8 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
|
|||
CURLU_DISALLOW_USER : 0) |
|
||||
(data->set.path_as_is ? CURLU_PATH_AS_IS : 0));
|
||||
if(uc) {
|
||||
DEBUGF(infof(data, "curl_url_set rejected %s", data->state.url));
|
||||
DEBUGF(infof(data, "curl_url_set rejected %s: %s", data->state.url,
|
||||
curl_url_strerror(uc)));
|
||||
return Curl_uc_to_curlcode(uc);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue