aboutsummaryrefslogtreecommitdiff
path: root/lib/transfer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/transfer.c')
-rw-r--r--lib/transfer.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index e98e1e01b..98cf70c1d 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -1889,9 +1889,29 @@ CURLcode Curl_perform(struct SessionHandle *data)
* performed after this do-while loop.
*/
- do {
- Curl_pgrsTime(data, TIMER_STARTSINGLE);
- res = Curl_connect(data, &conn);
+ do {
+ int urlchanged = FALSE;
+ do {
+ Curl_pgrsTime(data, TIMER_STARTSINGLE);
+ data->change.url_changed = FALSE;
+ res = Curl_connect(data, &conn);
+
+ /* If a callback (or something) has altered the URL we should use within
+ the Curl_connect(), we detect it here and act as if we are redirected
+ to the new URL */
+ urlchanged = data->change.url_changed;
+ if ((CURLE_OK == res) && urlchanged) {
+ char *newurl;
+ res = Curl_done(conn);
+ if(CURLE_OK == res) {
+ newurl = strdup(data->change.url);
+ res = Curl_follow(data, newurl);
+ if(res)
+ free(newurl);
+ }
+ }
+ } while (urlchanged && res == CURLE_OK) ;
+
if(res == CURLE_OK) {
res = Curl_do(&conn);