cURL cURL > Mailing List > Monthly Index > Single Mail

curl-tracker Archives

[curl:bugs] Re: #1461 curl_easy_reset removes proxy information via environment

From: JoSch <josch1337_at_users.sf.net>
Date: Sat, 06 Dec 2014 09:15:48 +0000

Hi,

Quoting Daniel Stenberg (2014-12-06 02:31:33)
> Really? To me it looks like it extracts and uses the proxy values at the time
> it performs the transfer, so an easy handle reset or not will be able to find
> the proxy. I don't see an error.

my apologies. I should've compiled a minimal example with which to reproduce
the effect I see before jumping to conclusions. If I had, then I would've
realized that it is not the curl_easy_reset which leads to the effect I'm
seeing but https is.

Here a code snippet:

--%<---------------------------------------------------------------------------
#include <stdio.h>
#include <curl/curl.h>
#include <stdlib.h>

int main(void)
{
    CURL *curl;
    CURLcode res;

    curl = curl_easy_init();
    //curl_easy_setopt(curl, CURLOPT_PROXY, getenv("http_proxy"));
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
    curl_easy_setopt(curl, CURLOPT_URL, "https://www.mediafire.com/api/user/get_session_token.php");
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "foo=bar");

    res = curl_easy_perform(curl);
    if(res != CURLE_OK)
        fprintf(stderr, "curl_easy_perform() failed: %s\n",
                curl_easy_strerror(res));

    curl_easy_cleanup(curl);
    curl_global_cleanup();
    return 0;
}
-->%---------------------------------------------------------------------------

Compile and run it:

        $ gcc -lcurl http-post.c && http_proxy=127.0.0.1:8080 ./a.out

Assuming that the http proxy 127.0.0.1 does NOT exist, this should throw an
error, should it not? But it doesn't and performs the request anyways.

Now remove the comment from the CURLOPT_PROXY line above and run it again. This
time it will fail with "Failed to connect to 127.0.0.1 port 8080: Connection
refused" as expected.

So why for https requests do I have to explicitly set CURLOPT_PROXY?

This might now just as well be something in the documentation I missed.

Thanks!

cheers, josch

---
** [bugs:#1461] curl_easy_reset removes proxy information via environment**
**Status:** open
**Created:** Fri Dec 05, 2014 11:58 AM UTC by JoSch
**Last Updated:** Sat Dec 06, 2014 01:31 AM UTC
**Owner:** Daniel Stenberg
Hi,
the documentation for curl_easy_reset says:
"Re-initializes all options previously set on a specified CURL handle to the default values. This puts back the handle to the same state as it was in when it was just created with curl_easy_init."
Suppose I have set the http_proxy environment variable. Then that one will be properly respected after a curl_easy_init. But once I do curl_easy_reset that information is lost.
So either above documentation has to be adapted to say "This puts back the handle to the same state as it was in when it was just created with curl_easy_init except that any proxy server set with the http_proxy environment variable is lost".
Or curl_easy_reset should respect the value of the http_proxy environment variable if it is set.
---
Sent from sourceforge.net because curl-tracker@cool.haxx.se is subscribed to http://sourceforge.net/p/curl/bugs/
To unsubscribe from further messages, a project admin can change settings at http://sourceforge.net/p/curl/admin/bugs/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.
Received on 2014-12-06

These mail archives are generated by hypermail.