summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Kearns <ext-shane.2.kearns@nokia.com>2012-02-22 20:24:58 +0000
committerQt by Nokia <qt-info@nokia.com>2012-03-09 17:15:35 +0100
commitfd60a3796ec4d4976965c81b7e14a538343050c4 (patch)
treea1a3cf103806825fb60070ba362e39c8caac9c12
parenteac482543acc02a078500208afbc93d1af2c4119 (diff)
Windows - handle both auto detect proxy settings together
If both "automatically detect settings" and "use automatic configuration script" are selected in internet options, then respect that. Because of performance issues, these are tried separately, and disabled if they fail. Task-number: QTBUG-13957 Task-number: QTBUG-10238 Change-Id: Ibc824d3039afeaf12c5ea82ed95287e5cf4e1776 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: Richard J. Moore <rich@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Shane Kearns <shane.kearns@accenture.com> (cherry picked from commit 4cc8209998c386a4372f10496f0c97f3d86f92bb)
-rw-r--r--src/network/kernel/qnetworkproxy_win.cpp38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp
index 594894cf89..025d3e1281 100644
--- a/src/network/kernel/qnetworkproxy_win.cpp
+++ b/src/network/kernel/qnetworkproxy_win.cpp
@@ -103,6 +103,7 @@ typedef struct {
#define WINHTTP_ERROR_BASE 12000
#define ERROR_WINHTTP_LOGIN_FAILURE (WINHTTP_ERROR_BASE + 15)
+#define ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT (WINHTTP_ERROR_BASE + 167)
#define ERROR_WINHTTP_AUTODETECTION_FAILED (WINHTTP_ERROR_BASE + 180)
QT_BEGIN_NAMESPACE
@@ -415,6 +416,9 @@ void QWindowsSystemProxy::init()
isAutoConfig = true;
memset(&autoProxyOptions, 0, sizeof autoProxyOptions);
autoProxyOptions.fAutoLogonIfChallenged = false;
+ //Although it is possible to specify dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT | WINHTTP_AUTOPROXY_CONFIG_URL
+ //this has poor performance (WPAD is attempted for every url, taking 2.5 seconds per interface,
+ //before the configured pac file is used)
if (ieProxyConfig.fAutoDetect) {
autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
autoProxyOptions.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DHCP |
@@ -462,6 +466,25 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
DWORD getProxyError = GetLastError();
if (!getProxySucceeded
+ && (ERROR_WINHTTP_AUTODETECTION_FAILED == getProxyError)) {
+ // WPAD failed
+ if (sp->autoConfigUrl.isEmpty()) {
+ //No config file could be retrieved on the network.
+ //Don't search for it next time again.
+ sp->isAutoConfig = false;
+ } else {
+ //pac file URL is specified as well, try using that
+ sp->autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
+ sp->autoProxyOptions.lpszAutoConfigUrl = (LPCWSTR)sp->autoConfigUrl.utf16();
+ getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
+ (LPCWSTR)url.toString().utf16(),
+ &sp->autoProxyOptions,
+ &proxyInfo);
+ getProxyError = GetLastError();
+ }
+ }
+
+ if (!getProxySucceeded
&& (ERROR_WINHTTP_LOGIN_FAILURE == getProxyError)) {
// We first tried without AutoLogon, because this might prevent caching the result.
// But now we've to enable it (http://msdn.microsoft.com/en-us/library/aa383153%28v=VS.85%29.aspx)
@@ -473,6 +496,13 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
getProxyError = GetLastError();
}
+ if (!getProxySucceeded
+ && (ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT == getProxyError)) {
+ // PAC file url is not connectable, or server returned error (e.g. http 404)
+ //Don't search for it next time again.
+ sp->isAutoConfig = false;
+ }
+
if (getProxySucceeded) {
// yes, we got a config for this URL
QString proxyBypass = QString::fromWCharArray(proxyInfo.lpszProxyBypass);
@@ -489,13 +519,7 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
return parseServerList(query, proxyServerList);
}
- // GetProxyForUrl failed
-
- if (ERROR_WINHTTP_AUTODETECTION_FAILED == getProxyError) {
- //No config file could be retrieved on the network.
- //Don't search for it next time again.
- sp->isAutoConfig = false;
- }
+ // GetProxyForUrl failed, fall back to static configuration
}
// static configuration