summaryrefslogtreecommitdiffstats
path: root/src/network/kernel/qnetworkproxy_win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/kernel/qnetworkproxy_win.cpp')
-rw-r--r--src/network/kernel/qnetworkproxy_win.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/network/kernel/qnetworkproxy_win.cpp b/src/network/kernel/qnetworkproxy_win.cpp
index 832a3badb9..fe9f088062 100644
--- a/src/network/kernel/qnetworkproxy_win.cpp
+++ b/src/network/kernel/qnetworkproxy_win.cpp
@@ -47,6 +47,7 @@
#include <qurl.h>
#include <private/qsystemlibrary_p.h>
#include <qnetworkinterface.h>
+#include <qdebug.h>
#include <string.h>
#include <qt_windows.h>
@@ -596,8 +597,16 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
url.setScheme(QLatin1String("https"));
}
+ QString urlQueryString = url.toString();
+ if (urlQueryString.size() > 2083) {
+ // calls to WinHttpGetProxyForUrl with urls longer than 2083 characters
+ // fail with error code ERROR_INVALID_PARAMETER(87), so we truncate it
+ qWarning("Proxy query URL too long for windows API, try with truncated URL");
+ urlQueryString = url.toString().left(2083);
+ }
+
bool getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
- (LPCWSTR)url.toString().utf16(),
+ (LPCWSTR)urlQueryString.utf16(),
&sp->autoProxyOptions,
&proxyInfo);
DWORD getProxyError = GetLastError();
@@ -614,7 +623,7 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
sp->autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
sp->autoProxyOptions.lpszAutoConfigUrl = (LPCWSTR)sp->autoConfigUrl.utf16();
getProxySucceeded = ptrWinHttpGetProxyForUrl(sp->hHttpSession,
- (LPCWSTR)url.toString().utf16(),
+ (LPCWSTR)urlQueryString.utf16(),
&sp->autoProxyOptions,
&proxyInfo);
getProxyError = GetLastError();
@@ -627,7 +636,7 @@ QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkPro
// 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(),
+ (LPCWSTR)urlQueryString.utf16(),
&sp->autoProxyOptions,
&proxyInfo);
getProxyError = GetLastError();