From 5c4fe0d8264a4a4f591d79cefe9676b099bdecf2 Mon Sep 17 00:00:00 2001 From: Jim Fuller Date: Thu, 1 Nov 2018 19:16:15 +0100 Subject: setopt: add CURLOPT_CURLU Allows an application to pass in a pre-parsed URL via a URL handle. Closes #3227 --- lib/transfer.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lib/transfer.c') diff --git a/lib/transfer.c b/lib/transfer.c index de6043d7d..32ca5a496 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -1353,17 +1353,30 @@ void Curl_init_CONNECT(struct Curl_easy *data) CURLcode Curl_pretransfer(struct Curl_easy *data) { CURLcode result; - if(!data->change.url) { + + if(!data->change.url && !data->set.uh) { /* we can't do anything without URL */ failf(data, "No URL set!"); return CURLE_URL_MALFORMAT; } + /* since the URL may have been redirected in a previous use of this handle */ if(data->change.url_alloc) { /* the already set URL is allocated, free it first! */ Curl_safefree(data->change.url); data->change.url_alloc = FALSE; } + + if(!data->change.url && data->set.uh) { + CURLUcode uc; + uc = curl_url_get(data->set.uh, + CURLUPART_URL, &data->set.str[STRING_SET_URL], 0); + if(uc) { + failf(data, "No URL set!"); + return CURLE_URL_MALFORMAT; + } + } + data->change.url = data->set.str[STRING_SET_URL]; /* Init the SSL session ID cache here. We do it here since we want to do it -- cgit v1.2.3