cURL / Mailing Lists / curl-library / Single Mail


Re: Proxy changes between transfers doesn't take effect immediately when using same handle

From: Ray Satiro via curl-library <>
Date: Sat, 23 Apr 2016 02:55:52 -0400

On 4/22/2016 4:16 PM, BoBo via curl-library wrote:
> Hi.
> Using the same handle I want to download the same URL (e.g.
> <>) first time without proxy
> and second time with wrong proxy.
> In order to achieve that I am setting proxy to empty string before the
> first download:
> curl_easy_setopt(handle, CURLOPT_PROXY, "");
> curl_easy_perform(handle);
> And setting it to something wrong before the second download:
> curl_easy_setopt(handle, CURLOPT_PROXY, "wrong:80");
> curl_easy_perform(handle);
> The expected correct result would be to succeed for the first time,
> and to fail for the second time, because the second download is using
> wrong proxy.
> But the actual result I am seeing is successful downloads for both
> cases. So I have the impression that although I am changing proxy
> option before triggering second transfer, the second transfer reuses
> the successfully established connection (one without proxy) instead of
> trying to create a new connection with new proxy information.
> options but didn't observe any change in
> behavior.<>
> Two observations that I have made are:
> 1. If instead of immediately triggering the second download I wait for
> 2 minutes and only then trigger the second download with wrong proxy,
> the behavior is as expected (the second download fails).
> 2. This issue occurs only when my wrong proxy address has port 80
> (somewrongproxy:80). If I specify wrong proxy with port other than 80,
> everything works as expected.
> So can you please help me figure out how is port 80 special in this
> case and how I can reuse same libcurl handle so that proxy changes
> between transfers take effect.

curl -v --next -x wrong:80
curl -v --next -x wrong:81

I think the reason it fails when 81 is because it's looking in the DNS
cache for port 81 and sees it doesn't exist whereas
port 80 exists.

CURLM_STATE_WAITRESOLVE in the state machine has [1]:

   dns = Curl_fetch_addr(conn, conn->, (int)conn->port);

But shouldn't that be conn->remote_port ?

And none of this explains why for wrong:80 it connects to as
if it's the proxy.


List admin:
Received on 2016-04-23