Re: Proxy changes between transfers doesn't take effect immediately when using same handle
Date: Sat, 23 Apr 2016 02:55:52 -0400
On 4/22/2016 4:16 PM, BoBo via curl-library wrote:
> Using the same handle I want to download the same URL (e.g.
> microsoft.com <http://www.microsoft.com/>) 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, "");
> And setting it to something wrong before the second download:
> curl_easy_setopt(handle, CURLOPT_PROXY, "wrong:80");
> 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.
> I have also tried with CURLOPT_FRESH_CONNECT and CURLOPT_FORBID_REUSE
> options but didn't observe any change in
> 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.
I think the reason it fails when 81 is because it's looking in the DNS
cache for test.com port 81 and sees it doesn't exist whereas test.com
port 80 exists.
CURLM_STATE_WAITRESOLVE in the state machine has :
dns = Curl_fetch_addr(conn, conn->host.name, (int)conn->port);
But shouldn't that be conn->remote_port ?
And none of this explains why for wrong:80 it connects to test.com:80 as
if it's the proxy.
List admin: https://cool.haxx.se/list/listinfo/curl-library
Received on 2016-04-23