diff options
author | Daniel Stenberg <daniel@haxx.se> | 2018-10-22 00:09:49 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-10-23 11:43:41 +0200 |
commit | 6535b9303df83eb3f1e95fded0d778e51d9aa50c (patch) | |
tree | 694870098d0db8871e0246117003d1bcc1ee3b7a /lib | |
parent | ca10fae6fc0131476b79b293e8d7087455c04ead (diff) |
Curl_follow: return better errors on URL problems
... by making the converter function global and accessible.
Closes #3153
Diffstat (limited to 'lib')
-rw-r--r-- | lib/transfer.c | 6 | ||||
-rw-r--r-- | lib/url.c | 18 | ||||
-rw-r--r-- | lib/url.h | 1 |
3 files changed, 12 insertions, 13 deletions
diff --git a/lib/transfer.c b/lib/transfer.c index e6d98cfa4..c7f4ef9f3 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -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 @@ -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; } @@ -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); |