I am fairly new to HTTP Protocols involving proxies and authentication. I am working on an application that runs on Windows and uses the host network to send/receive HTTP/S requests. It also uses Libcurl to help the transfer.

However, I have a few issues when I have to use a proxy. Since I am on a network, I have a proxy defined for certain URLs with a PAC file. Since Libcurl does not have Javascript support, I use PACParser to parse the PAC file and determine the proxy.

When I use the proxy I get 407 authentication required. I am not sure how to overcome proxy authentication. I tried various available settings with CURL like BASIC / DIGEST / NTLM. None of them seems to work. But if I hardcode the username and password in the request I see the request go through.

How can I avoid hardcoding the username/password and stil ensure that proxy usage will work?

1 Answer 1


See libcurl-tutorial (3), section Environment Variables:

libcurl automatically checks and uses a set of environment
variables to know what proxies to use for certain
protocols. The names of the variables are following an
ancient de facto standard and are built up
as "[protocol]_proxy" (note the lower casing). Which makes
the variable 'http_proxy' checked for a name of a proxy to
use when the input URL is HTTP. Following the same rule, the
variable named 'ftp_proxy' is checked for FTP URLs. Again,
the proxies are always HTTP proxies, the different names of
the variables simply allows different HTTP proxies to be

The proxy environment variable contents should be in the
format "[protocol://][user:password@]machine[:port]".

So you have to enter the proxy in the environment variable settings, not the network settings.

  • But i am trying to understand a way to achieve proxy authentication if my proxy mandates one. May 16, 2013 at 16:21
  • adding user:password@ does not work?
    – wnrph
    May 17, 2013 at 8:29
  • i was assuming Curl can negotiate with the host machine to retrieve the user name and password during transfer. It is something we need to derive the username and password? <b> I tried to explore winhttp "http query option" to get the username and pwd. Is this something a right direction Or there are someother mechanism to fetch the proxy username and password May 17, 2013 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.