summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-07-05 13:13:28 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-07-05 13:17:43 (GMT)
commitf9ae198f02ebda5279ad7a98f68871f02f3a382b (patch)
treed604bc7946f6aae5b09dc4430418dfabc2db6991 /src/network
parentf8906a729761203866b100f5cd74e452cc94c451 (diff)
downloadQt-f9ae198f02ebda5279ad7a98f68871f02f3a382b.zip
Qt-f9ae198f02ebda5279ad7a98f68871f02f3a382b.tar.gz
Qt-f9ae198f02ebda5279ad7a98f68871f02f3a382b.tar.bz2
Network: Optimize HTTP proxy lookup on Windows
Only try auto config retrieval once. Patch by Kai Koehne. Task-number: QTBUG-10106
Diffstat (limited to 'src/network')
-rw-r--r--src/network/kernel/qnetworkproxy_win.cpp37
1 files changed, 32 insertions, 5 deletions
diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp
index e801738..537107e 100644
--- a/src/network/kernel/qnetworkproxy_win.cpp
+++ b/src/network/kernel/qnetworkproxy_win.cpp
@@ -100,6 +100,10 @@ typedef struct {
#define WINHTTP_NO_PROXY_NAME NULL
#define WINHTTP_NO_PROXY_BYPASS NULL
+#define WINHTTP_ERROR_BASE 12000
+#define ERROR_WINHTTP_LOGIN_FAILURE (WINHTTP_ERROR_BASE + 15)
+#define ERROR_WINHTTP_AUTODETECTION_FAILED (WINHTTP_ERROR_BASE + 180)
+
QT_BEGIN_NAMESPACE
typedef BOOL (WINAPI * PtrWinHttpGetProxyForUrl)(HINTERNET, LPCWSTR, WINHTTP_AUTOPROXY_OPTIONS*, WINHTTP_PROXY_INFO*);
@@ -320,7 +324,7 @@ void QWindowsSystemProxy::init()
isAutoConfig = true;
memset(&autoProxyOptions, 0, sizeof autoProxyOptions);
- autoProxyOptions.fAutoLogonIfChallenged = true;
+ autoProxyOptions.fAutoLogonIfChallenged = false;
if (ieProxyConfig.fAutoDetect) {
autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
autoProxyOptions.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DHCP |
@@ -377,10 +381,26 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
// change the scheme to https, maybe it'll work
url.setScheme(QLatin1String("https"));
}
- if (ptrWinHttpGetProxyForUrl(sp->hHttpSession,
- (LPCWSTR)url.toString().utf16(),
- &sp->autoProxyOptions,
- &proxyInfo)) {
+
+ bool getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
+ (LPCWSTR)url.toString().utf16(),
+ &sp->autoProxyOptions,
+ &proxyInfo);
+ DWORD 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)
+ sp->autoProxyOptions.fAutoLogonIfChallenged = TRUE;
+ getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
+ (LPCWSTR)url.toString().utf16(),
+ &sp->autoProxyOptions,
+ &proxyInfo);
+ getProxyError = GetLastError();
+ }
+
+ if (getProxySucceeded) {
// yes, we got a config for this URL
QString proxyBypass = QString::fromWCharArray(proxyInfo.lpszProxyBypass);
QStringList proxyServerList = splitSpaceSemicolon(QString::fromWCharArray(proxyInfo.lpszProxy));
@@ -395,6 +415,13 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
}
// 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;
+ }
+
return sp->defaultResult;
}