Sei sulla pagina 1di 2

IN WinHttpOpen(..) [ https://msdn.microsoft.

com/en-
us/library/windows/desktop/aa384098(v=vs.85).aspx ] currently we use
WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY (works on 8.1 & above)

Currently we are doing this: WinHttpOpen(nullptr, WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY,


WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, NULL);

=======================================================================

WINHTTP_ACCESS_TYPE_DEFAULT_PROXY is the flag which doesn’t inherit browser proxy settings &
which is why prob. it worked for all 3 combos (Basic, Basic+PAC, Basic+WPAD) even when the
credentials were not present.

======================================================================

If we use WinHttpGetIEProxyConfigForCurrentUser(WINHTTP_CURRENT_USER_IE_PROXY_CONFIG*
lProxyInfo)

Where WINHTTP_CURRENT_USER_IE_PROXY_CONFIG is

typedef struct {
BOOL fAutoDetect; => if true, should imply WPAD conf.(Web Proxy Auto-Discovery) : CASE 3
LPWSTR lpszAutoConfigUrl; => if not null & fAutoDetect is false implies PAC conf. & this string has URL
for PAC file : CASE 2
LPWSTR lpszProxy; => If both above are not set, implies simple proxy & proxy URL is this : CASE 1
LPWSTR lpszProxyBypass; // bypass URLs
} WINHTTP_CURRENT_USER_IE_PROXY_CONFIG;

=====================================================================

CASE :1

For BASIC simple only proxy if we try this => works


WinHttpOpen(nullptr, WINHTTP_ACCESS_TYPE_NAMED_PROXY, lProxyInfo.lpszProxy,
lProxyInfo.lpszProxyBypass, NULL);

=====================================================================

CASE :3

If WPAD conf (fAutoDetect is true) we can use WinHttpGetProxyForUrl to retrieve the proxy for the
request as mentioned here (https://msdn.microsoft.com/en-
us/library/windows/desktop/aa384075(v=vs.85).aspx) in form of WINHTTP_PROXY_INFO .

struct WINHTTP_PROXY_INFO {
DWORD dwAccessType;
LPWSTR lpszProxy;
LPWSTR lpszProxyBypass;
};
As WinHttpGetProxyForUrl uses WINHTTP_AUTOPROXY_OPTIONS which we can set as per our req.
(https://msdn.microsoft.com/en-us/library/windows/desktop/aa384123(v=vs.85).aspx) and

[ Note: WPAD we set via this registry=> HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet ->
services -> Tcpip -> Parameters]

=======================================================================

CASE :2

If PAC (lpszAutoConfigUrl is set & AutoDetect False) we should try to get proxy URL using this structure
WINHTTP_AUTOPROXY_OPTIONS config as input for WinHttpGetProxyForUrl / WinHttpGetProxyForUrl
Ex & we get output WINHTTP_PROXY_INFO which has proxy config details.

==================================================================

Complete Examples are here: https://msdn.microsoft.com/en-


us/library/windows/desktop/aa384122(v=vs.85).aspx as well

==================================================================

Other useful functions – WinHttpDetectAutoProxyConfigUrl, WinHttpGetProxyForUrlEx,


WinHttpCreateProxyResolver

Potrebbero piacerti anche