summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2017-01-11 08:32:37 +0100
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2017-01-11 10:45:26 +0000
commitff5ce39e2195392289935040de4a301b1ccb1200 (patch)
tree54aa5871d30937eb277c19ad139f54b05b389eac /src
parent1636f3bc9294cb3f3612bcc02bd3be305fb3f707 (diff)
qhttp2protocolhandler - handle proxies correctly
For requests through proxy, the Request-URI (':path' header) must contain full url. Change-Id: Ibecdf4556b0cecf731da0f89b241bb86a07fa3ad Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/network/access/qhttp2protocolhandler.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp
index f7383d1d3a..6460751b00 100644
--- a/src/network/access/qhttp2protocolhandler.cpp
+++ b/src/network/access/qhttp2protocolhandler.cpp
@@ -53,6 +53,10 @@
#include <QtCore/qlist.h>
#include <QtCore/qurl.h>
+#ifndef QT_NO_NETWORKPROXY
+#include <QtNetwork/qnetworkproxy.h>
+#endif
+
#include <algorithm>
#include <vector>
@@ -61,7 +65,8 @@ QT_BEGIN_NAMESPACE
namespace
{
-HPack::HttpHeader build_headers(const QHttpNetworkRequest &request, quint32 maxHeaderListSize)
+HPack::HttpHeader build_headers(const QHttpNetworkRequest &request, quint32 maxHeaderListSize,
+ bool useProxy)
{
using namespace HPack;
@@ -73,7 +78,7 @@ HPack::HttpHeader build_headers(const QHttpNetworkRequest &request, quint32 maxH
const auto auth = request.url().authority(QUrl::FullyEncoded | QUrl::RemoveUserInfo).toLatin1();
header.push_back(HeaderField(":authority", auth));
header.push_back(HeaderField(":method", request.methodName()));
- header.push_back(HeaderField(":path", request.uri(false)));
+ header.push_back(HeaderField(":path", request.uri(useProxy)));
header.push_back(HeaderField(":scheme", request.url().scheme().toLatin1()));
HeaderSize size = header_size(header);
@@ -403,7 +408,11 @@ bool QHttp2ProtocolHandler::sendHEADERS(Stream &stream)
frameWriter.append(quint32()); // No stream dependency in Qt.
frameWriter.append(stream.weight());
- const auto headers = build_headers(stream.request(), maxHeaderListSize);
+ bool useProxy = false;
+#ifndef QT_NO_NETWORKPROXY
+ useProxy = m_connection->d_func()->networkProxy.type() != QNetworkProxy::NoProxy;
+#endif
+ const auto headers = build_headers(stream.request(), maxHeaderListSize, useProxy);
if (!headers.size()) // nothing fits into maxHeaderListSize
return false;