Search code examples
c++proxyhttp-authenticationwinhttp

WinHTTP: using proxy with authentication


guys! I have to use proxy with authentication in my app where I connect to the server. (MFC app, WinHTTP lib). There is no problem to use simple proxy without username/pass. But how to specify auth method?

I tried the following, but it didn't work and returned me Error 87 (Incorrect PArameter) http://username:password@hostname.com

Is it correct?

Thanks,


Solution

  • It is not correct. First of all, password is not allowed to be embedded into the URI. However it is not the source of the problem: to provide WinHTTP with proxy authentication details you are expected to use WinHttpSetCredentials with:

    AuthTargets [in]

    WINHTTP_AUTH_TARGET_PROXY - Credentials are passed to a proxy.