--- lib/multi.c 2008-08-23 16:11:38.000000000 +0400 +++ /home/redbaron/forks/curl-7.19.0/lib/multi.c 2008-09-12 21:23:48.698843459 +0400 @@ -1313,7 +1313,7 @@ checkPendPipeline(easy->easy_conn); /* When we follow redirects, must to go back to the CONNECT state */ - if(easy->easy_handle->req.newurl || retry) { + if(easy->easy_handle->req.newurl ||retry) { if(!retry) { /* if the URL is a follow-location and not just a retried request then figure out the URL here */ @@ -1327,8 +1327,8 @@ if(easy->result == CURLE_OK) easy->result = Curl_follow(easy->easy_handle, newurl, follow); if(CURLE_OK == easy->result) { - multistate(easy, CURLM_STATE_CONNECT); - result = CURLM_CALL_MULTI_PERFORM; + multistate(easy, CURLM_STATE_CONNECT); + result = CURLM_CALL_MULTI_PERFORM; } else /* Since we "took it", we are in charge of freeing this on @@ -1337,6 +1337,14 @@ } else { /* after the transfer is done, go DONE */ + if (easy->easy_handle->req.location) { + newurl = easy->easy_handle->req.location; + easy->easy_handle->req.location = NULL; + easy->result = Curl_follow(easy->easy_handle, newurl, FOLLOW_FAKE); + if (easy->result != CURLE_OK) + free(newurl); + break; + } multistate(easy, CURLM_STATE_DONE); result = CURLM_CALL_MULTI_PERFORM; }