1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-23 16:48:49 -05:00

Curl_follow: return better errors on URL problems

... by making the converter function global and accessible.

Closes #3153
This commit is contained in:
Daniel Stenberg 2018-10-22 00:09:49 +02:00
parent ca10fae6fc
commit 6535b9303d
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
3 changed files with 12 additions and 13 deletions

View File

@ -1516,13 +1516,11 @@ CURLcode Curl_follow(struct Curl_easy *data,
DEBUGASSERT(data->state.uh);
uc = curl_url_set(data->state.uh, CURLUPART_URL, newurl, 0);
if(uc)
/* TODO: consider an error code remap here */
return CURLE_URL_MALFORMAT;
return Curl_uc_to_curlcode(uc);
uc = curl_url_get(data->state.uh, CURLUPART_URL, &newurl, 0);
if(uc)
/* TODO: consider an error code remap here */
return CURLE_OUT_OF_MEMORY;
return Curl_uc_to_curlcode(uc);
if(type == FOLLOW_FAKE) {
/* we're only figuring out the new url if we would've followed locations

View File

@ -1996,7 +1996,7 @@ static CURLcode findprotocol(struct Curl_easy *data,
}
static CURLcode uc_to_curlcode(CURLUcode uc)
CURLcode Curl_uc_to_curlcode(CURLUcode uc)
{
switch(uc) {
default:
@ -2048,11 +2048,11 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
CURLU_DISALLOW_USER : 0) |
(data->set.path_as_is ? CURLU_PATH_AS_IS : 0));
if(uc)
return uc_to_curlcode(uc);
return Curl_uc_to_curlcode(uc);
uc = curl_url_get(uh, CURLUPART_SCHEME, &data->state.up.scheme, 0);
if(uc)
return uc_to_curlcode(uc);
return Curl_uc_to_curlcode(uc);
result = findprotocol(data, conn, data->state.up.scheme);
if(result)
@ -2067,7 +2067,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
conn->bits.user_passwd = TRUE;
}
else if(uc != CURLUE_NO_USER)
return uc_to_curlcode(uc);
return Curl_uc_to_curlcode(uc);
uc = curl_url_get(uh, CURLUPART_PASSWORD, &data->state.up.password,
CURLU_URLDECODE);
@ -2078,7 +2078,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
conn->bits.user_passwd = TRUE;
}
else if(uc != CURLUE_NO_PASSWORD)
return uc_to_curlcode(uc);
return Curl_uc_to_curlcode(uc);
uc = curl_url_get(uh, CURLUPART_OPTIONS, &data->state.up.options,
CURLU_URLDECODE);
@ -2088,7 +2088,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
return CURLE_OUT_OF_MEMORY;
}
else if(uc != CURLUE_NO_OPTIONS)
return uc_to_curlcode(uc);
return Curl_uc_to_curlcode(uc);
uc = curl_url_get(uh, CURLUPART_HOST, &data->state.up.hostname, 0);
if(uc) {
@ -2098,7 +2098,7 @@ static CURLcode parseurlandfillconn(struct Curl_easy *data,
uc = curl_url_get(uh, CURLUPART_PATH, &data->state.up.path, 0);
if(uc)
return uc_to_curlcode(uc);
return Curl_uc_to_curlcode(uc);
uc = curl_url_get(uh, CURLUPART_PORT, &data->state.up.port,
CURLU_DEFAULT_PORT);
@ -3082,12 +3082,12 @@ static CURLcode override_login(struct Curl_easy *data,
if(user_changed) {
uc = curl_url_set(data->state.uh, CURLUPART_USER, *userp, 0);
if(uc)
return uc_to_curlcode(uc);
return Curl_uc_to_curlcode(uc);
}
if(passwd_changed) {
uc = curl_url_set(data->state.uh, CURLUPART_PASSWORD, *passwdp, 0);
if(uc)
return uc_to_curlcode(uc);
return Curl_uc_to_curlcode(uc);
}
return CURLE_OK;
}

View File

@ -50,6 +50,7 @@ CURLcode Curl_init_userdefined(struct Curl_easy *data);
void Curl_freeset(struct Curl_easy * data);
/* free the URL pieces */
void Curl_up_free(struct Curl_easy *data);
CURLcode Curl_uc_to_curlcode(CURLUcode uc);
CURLcode Curl_close(struct Curl_easy *data); /* opposite of curl_open() */
CURLcode Curl_connect(struct Curl_easy *, struct connectdata **,
bool *async, bool *protocol_connect);