summaryrefslogtreecommitdiffstats
path: root/src/network/access/qhttp2protocolhandler.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-10-04 10:41:19 +0200
committerLiang Qi <liang.qi@qt.io>2017-10-04 13:41:04 +0200
commitbc5f45052fd8f9a5481a37a6a4d55c7f6cbf037d (patch)
tree2c20e6c42ccd008e431a8d485450713883eacbb5 /src/network/access/qhttp2protocolhandler.cpp
parentb8947e9194f0f88f464448ac51f6a05113d36a33 (diff)
parent3faf8f4d48abd982be8470786cc5f61372519722 (diff)
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts: src/corelib/global/qconfig-bootstrapped.h src/corelib/global/qglobal.h src/corelib/tools/qcryptographichash.cpp src/corelib/tools/qcryptographichash.h src/corelib/tools/qmessageauthenticationcode.cpp src/plugins/platforms/windows/qwindowswindow.h tests/auto/gui/kernel/qwindow/BLACKLIST tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST Change-Id: Ib68112de985a3d714c2071f47c10e907e4f0229a
Diffstat (limited to 'src/network/access/qhttp2protocolhandler.cpp')
-rw-r--r--src/network/access/qhttp2protocolhandler.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp
index 5032f6017f..a651fc4092 100644
--- a/src/network/access/qhttp2protocolhandler.cpp
+++ b/src/network/access/qhttp2protocolhandler.cpp
@@ -1042,12 +1042,26 @@ void QHttp2ProtocolHandler::updateStream(Stream &stream, const HPack::HttpHeader
}
const auto httpReplyPrivate = httpReply->d_func();
+
+ // For HTTP/1 'location' is handled (and redirect URL set) when a protocol
+ // handler emits channel->allDone(). Http/2 protocol handler never emits
+ // allDone, since we have many requests multiplexed in one channel at any
+ // moment and we are probably not done yet. So we extract url and set it
+ // here, if needed.
+ int statusCode = 0;
+ QUrl redirectUrl;
+
for (const auto &pair : headers) {
const auto &name = pair.name;
auto value = pair.value;
+ // TODO: part of this code copies what SPDY protocol handler does when
+ // processing headers. Binary nature of HTTP/2 and SPDY saves us a lot
+ // of parsing and related errors/bugs, but it would be nice to have
+ // more detailed validation of headers.
if (name == ":status") {
- httpReply->setStatusCode(value.left(3).toInt());
+ statusCode = value.left(3).toInt();
+ httpReply->setStatusCode(statusCode);
httpReplyPrivate->reasonPhrase = QString::fromLatin1(value.mid(4));
} else if (name == ":version") {
httpReplyPrivate->majorVersion = value.at(5) - '0';
@@ -1058,6 +1072,8 @@ void QHttp2ProtocolHandler::updateStream(Stream &stream, const HPack::HttpHeader
if (ok)
httpReply->setContentLength(length);
} else {
+ if (name == "location")
+ redirectUrl = QUrl::fromEncoded(value);
QByteArray binder(", ");
if (name == "set-cookie")
binder = "\n";
@@ -1065,6 +1081,9 @@ void QHttp2ProtocolHandler::updateStream(Stream &stream, const HPack::HttpHeader
}
}
+ if (QHttpNetworkReply::isHttpRedirect(statusCode) && redirectUrl.isValid())
+ httpReply->setRedirectUrl(redirectUrl);
+
if (connectionType == Qt::DirectConnection)
emit httpReply->headerChanged();
else