With HTTP, you got a 407 response to the HEAD request, and then it said "No error" because it got a valid HTTP response. But it's not the HTTP response you actually wanted. You need to set the password so that curl will send the authentication when it gets a 407 response.
With HTTPS, you got a 407 response and then it said there was an error completing the CONNECT step. The difference is that HTTPS needs a CONNECT to get through the proxy, then it sets up an SSL tunnel, then it sends another HTTP request over that tunnel, so it printed an error message because it had more steps to complete that it couldn't get to. ________________________________ From: curl-library [[email protected]] on behalf of Valerio Borsò [[email protected]] Sent: Wednesday, February 18, 2015 11:39 AM To: libcurl development Subject: RE: Ntlm proxy and Http 407 error So why using http all is OK? I'using ntlm for auth and it takes credebtial from windows login Il 18/feb/2015 17:26 "Joe Mason" <[email protected]<mailto:[email protected]>> ha scritto: You also need to set the password with CURLOPT_PROXYUSERNAME and CURLOPT_PROXYPASSWORD. ________________________________ From: curl-library [[email protected]<mailto:[email protected]>] on behalf of Valerio Borsò [[email protected]<mailto:[email protected]>] Sent: Wednesday, February 18, 2015 11:00 AM To: [email protected]<mailto:[email protected]> Subject: Ntlm proxy and Http 407 error Hi All!! I'm developing a small application. For testing purpouse i'm tryng to "ping" google using libcurl while behind an ntlm proxy. This is my c++ code: CURLcode testConnection(void) { CURL *curl; CURLcode res = CURLE_OK; res = curl_global_init(CURL_GLOBAL_ALL); curl = curl_easy_init(); if (curl) { cout << "Url: " << curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com")) << "\n"; cout << "T-out: " << curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 3)) << "\n"; cout << "No_body: " << curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_NOBODY, true)) << "\n"; cout << "Proxy Url: " << curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_PROXY, "proxyrm.wind.root.it<http://proxyrm.wind.root.it>")) << "\n"; cout << "Proxy Port: " << curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_PROXYPORT, 8080)) << "\n"; cout << "Ntml: " << curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_NTLM)) << "\n"; cout << "Verbose: " << curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_VERBOSE, true)) << "\n"; res = curl_easy_perform(curl); curl_easy_cleanup(curl); } else res = CURLE_FAILED_INIT; curl_global_cleanup(); return res; } All this went good, since the verbose output is the following. Url: No error T-out: No error No_body: No error Proxy Url: No error Proxy Port: No error Ntml: No error Verbose: No error * About to connect() to proxy proxyrm.wind.root.it<http://proxyrm.wind.root.it> port 8080 (#0) * Trying 10.8.54.115... * Connected to proxyrm.wind.root.it<http://proxyrm.wind.root.it> (10.8.54.115) port 8080 (#0) > HEAD http://www.google.com HTTP/1.1 Host: www.google.com<http://www.google.com> Accept: */* Proxy-Connection: Keep-Alive < HTTP/1.1 407 Proxy Authentication Required < Proxy-Authenticate: NTLM < Proxy-Authenticate: BASIC realm="windroot" < Cache-Control: no-cache < Pragma: no-cache < Content-Type: text/html; charset=utf-8 * HTTP/1.1 proxy connection set close! < Proxy-Connection: close < Set-Cookie: BCSI-CS-602d36a7505d346e=2; Path=/ < Connection: close < Content-Length: 989 < * Closing connection 0 Curl Final: No error But, if i try to ping https://google.com using this line cout << "Url: " << curl_easy_strerror(curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com")) << "\n"; The result become this Url: No error T-out: No error No_body: No error Proxy Url: No error Proxy Port: No error Ntml: No error Ntml: No error Ntml: No error Verbose: No error * About to connect() to proxy proxyrm.wind.root.it<http://proxyrm.wind.root.it> port 8080 (#0 * Trying 10.8.54.115... * Connected to proxyrm.wind.root.it<http://proxyrm.wind.root.it> (10.8.54.115) port 8080 (#0) * Establish HTTP proxy tunnel to www.google.com:443<http://www.google.com:443> > CONNECT www.google.com:443<http://www.google.com:443> HTTP/1.1 Host: www.google.com:443<http://www.google.com:443> Proxy-Connection: Keep-Alive < HTTP/1.1 407 Proxy Authentication Required < Proxy-Authenticate: NTLM < Proxy-Authenticate: BASIC realm="windroot" < Cache-Control: no-cache < Pragma: no-cache < Content-Type: text/html; charset=utf-8 < Proxy-Connection: close < Set-Cookie: BCSI-CS-602d36a7505d346e=2; Path=/ < Connection: close < Content-Length: 1135 < * Ignore 1135 bytes of response-body * Received HTTP code 407 from proxy after CONNECT * Connection #0 to host proxyrm.wind.root.it<http://proxyrm.wind.root.it> left intact Curl Final: Failure when receiving data from the peer Using curl in command line allow me to ping https (i have to specify the -k argument) but i don't know if this is really relevant. Someone can help me to figure out what's happening? And how to avoid that? ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
