From ff5ce39e2195392289935040de4a301b1ccb1200 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Wed, 11 Jan 2017 08:32:37 +0100 Subject: qhttp2protocolhandler - handle proxies correctly For requests through proxy, the Request-URI (':path' header) must contain full url. Change-Id: Ibecdf4556b0cecf731da0f89b241bb86a07fa3ad Reviewed-by: Edward Welbourne --- src/network/access/qhttp2protocolhandler.cpp | 15 ++++++++++++--- 1 file 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 #include +#ifndef QT_NO_NETWORKPROXY +#include +#endif + #include #include @@ -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; -- cgit v1.2.3