Another auto proxy tweak

This commit is contained in:
Marek Roszko 2021-11-13 21:23:32 -05:00
parent b747ae5bdf
commit f5fc9fa11f
1 changed files with 14 additions and 2 deletions

View File

@ -146,8 +146,9 @@ bool KIPLATFORM::ENV::GetSystemProxyConfig( const wxString& aURL, PROXY_CONFIG&
autoProxyOptions.lpszAutoConfigUrl = ieProxyConfig.lpszAutoConfigUrl;
}
}
else
else if( GetLastError() == ERROR_FILE_NOT_FOUND )
{
// this is the only error code where we want to continue attempting to find a proxy
autoProxyDetect = true;
}
@ -171,11 +172,22 @@ bool KIPLATFORM::ENV::GetSystemProxyConfig( const wxString& aURL, PROXY_CONFIG&
WINHTTP_AUTO_DETECT_TYPE_DHCP | WINHTTP_AUTO_DETECT_TYPE_DNS_A;
}
autoProxyOptions.fAutoLogonIfChallenged = TRUE;
// dont do auto logon at first, this allows windows to use an cache
// per https://docs.microsoft.com/en-us/windows/win32/winhttp/autoproxy-cache
autoProxyOptions.fAutoLogonIfChallenged = FALSE;
autoProxyDetect = WinHttpGetProxyForUrl( proxyResolveSession, aURL.c_str(),
&autoProxyOptions, &autoProxyInfo );
if( !autoProxyDetect && GetLastError() == ERROR_WINHTTP_LOGIN_FAILURE )
{
autoProxyOptions.fAutoLogonIfChallenged = TRUE;
// try again with auto login now
autoProxyDetect = WinHttpGetProxyForUrl( proxyResolveSession, aURL.c_str(),
&autoProxyOptions, &autoProxyInfo );
}
WinHttpCloseHandle( proxyResolveSession );
}