public WinHTTPAutoProxy(bool bAutoDiscover, string sAutoBrowserUrl) { this._bUseAutoDiscovery = bAutoDiscover; if (!string.IsNullOrEmpty(sAutoBrowserUrl)) { this._sPACScriptLocation = sAutoBrowserUrl; } this._oAPO = GetAutoProxyOptionsStruct(this._sPACScriptLocation, this._bUseAutoDiscovery); this._hSession = WinHTTPNative.WinHttpOpen("SDVP", 1, IntPtr.Zero, IntPtr.Zero, 0); }
private static WinHTTPNative.WINHTTP_AUTOPROXY_OPTIONS GetAutoProxyOptionsStruct(string sPAC, bool bUseAutoDetect) { WinHTTPNative.WINHTTP_AUTOPROXY_OPTIONS winhttp_autoproxy_options = new WinHTTPNative.WINHTTP_AUTOPROXY_OPTIONS(); if (SDVPApplication.Prefs.GetBoolPref("SDVP.network.gateway.DetermineInProcess", false)) { winhttp_autoproxy_options.dwFlags = 0x10000; } else { winhttp_autoproxy_options.dwFlags = 0; } if (bUseAutoDetect) { winhttp_autoproxy_options.dwFlags |= 1; winhttp_autoproxy_options.dwAutoDetectFlags = 3; } if (sPAC != null) { winhttp_autoproxy_options.dwFlags |= 2; winhttp_autoproxy_options.lpszAutoBrowserUrl = sPAC; } winhttp_autoproxy_options.fAutoLoginIfChallenged = Browser.bAutoProxyLogon; return(winhttp_autoproxy_options); }