cURL / Mailing Lists / curl-library / Single Mail


407 "Proxy Authentication Required" error is not communicated properly when using HTTP tunneling

From: Joshua Kwan <>
Date: Tue, 7 Jul 2009 15:18:56 -0700


We have an app using libcurl that behaves differently depending on whether the URL is HTTP or HTTPS. Currently, we're developing support code to allow the app to notice when it must prompt the user for proxy server credentials. So our test case is "if you enter no credentials or the wrong credentials when they are required, cURL should report HTTP code 407."

When using a HTTP URL, we correctly get this set of results:
- Normal HTTP proxying code is used within curl.
- When a download finishes, curl_multi_info_read returns CURLE_OK in msg->data.result.
- We use curl_easy_getinfo on the easy handle to check the HTTP status code.
- This returns 407 and our app has the right behavior of prompting for credentials.

When using an HTTPS URL, this is what happens:
- HTTP proxy *tunneling* code is used within curl, judging by the log messages.
- When a download finishes, curl_multi_info_read returns CURLE_RECV_ERROR.
- I try to use curl_easy_getinfo anyway to check for the 407, but it just returns 0.

So there seems to be no way to discover the 407. However, the verbose logging we have for this situation is as follows:
'cURL debug: Received HTTP code 407 from proxy after CONNECT'

This indicates that cURL is indeed seeing the 407, but is not passing it back to us. Is this a bug? Is there a better way to probe for this 407 error? Because we need to pass it into our app.

Received on 2009-07-08