diff options
-rw-r--r-- | src/network/access/qhttp2protocolhandler.cpp | 2 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyhttpimpl.cpp | 9 | ||||
-rw-r--r-- | src/network/access/qnetworkrequest.cpp | 5 | ||||
-rw-r--r-- | tests/auto/network/access/http2/tst_http2.cpp | 9 |
4 files changed, 22 insertions, 3 deletions
diff --git a/src/network/access/qhttp2protocolhandler.cpp b/src/network/access/qhttp2protocolhandler.cpp index 60313422da..555f1ba0ef 100644 --- a/src/network/access/qhttp2protocolhandler.cpp +++ b/src/network/access/qhttp2protocolhandler.cpp @@ -1387,6 +1387,8 @@ void QHttp2ProtocolHandler::initReplyFromPushPromise(const HttpMessagePair &mess { Q_ASSERT(promisedData.contains(cacheKey)); auto promise = promisedData.take(cacheKey); + Q_ASSERT(message.second); + message.second->setSpdyWasUsed(true); qCDebug(QT_HTTP2) << "found cached/promised response on stream" << promise.reservedID; diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index 5cd0747e34..bdb23ede1d 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -1234,7 +1234,14 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData(const QList<QPair<QByte } q->setAttribute(QNetworkRequest::HttpPipeliningWasUsedAttribute, pu); - q->setAttribute(QNetworkRequest::SpdyWasUsedAttribute, spdyWasUsed); + const QVariant http2Allowed = request.attribute(QNetworkRequest::HTTP2AllowedAttribute); + if (http2Allowed.isValid() && http2Allowed.toBool()) { + q->setAttribute(QNetworkRequest::HTTP2WasUsedAttribute, spdyWasUsed); + q->setAttribute(QNetworkRequest::SpdyWasUsedAttribute, false); + } else { + q->setAttribute(QNetworkRequest::SpdyWasUsedAttribute, spdyWasUsed); + q->setAttribute(QNetworkRequest::HTTP2WasUsedAttribute, false); + } // reconstruct the HTTP header QList<QPair<QByteArray, QByteArray> > headerMap = hm; diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index e95187de30..60701d45be 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -266,7 +266,10 @@ QT_BEGIN_NAMESPACE allowed to use HTTP/2 with this request. This applies to SSL requests or 'cleartext' HTTP/2. - \omitvalue HTTP2WasUsedAttribute + \value HTTP2WasUsedAttribute + Replies only, type: QMetaType::Bool (default: false) + Indicates whether HTTP/2 was used for receiving this reply. + (This value was introduced in 5.9.) \value EmitAllUploadProgressSignalsAttribute Requests only, type: QMetaType::Bool (default: false) diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp index e7609b3243..d7a57f5e26 100644 --- a/tests/auto/network/access/http2/tst_http2.cpp +++ b/tests/auto/network/access/http2/tst_http2.cpp @@ -590,8 +590,15 @@ void tst_Http2::replyFinished() { QVERIFY(nRequests); - if (const auto reply = qobject_cast<QNetworkReply *>(sender())) + if (const auto reply = qobject_cast<QNetworkReply *>(sender())) { QCOMPARE(reply->error(), QNetworkReply::NoError); + const QVariant http2Used(reply->attribute(QNetworkRequest::HTTP2WasUsedAttribute)); + QVERIFY(http2Used.isValid()); + QVERIFY(http2Used.toBool()); + const QVariant spdyUsed(reply->attribute(QNetworkRequest::SpdyWasUsedAttribute)); + QVERIFY(spdyUsed.isValid()); + QVERIFY(!spdyUsed.toBool()); + } --nRequests; if (!nRequests && serverGotSettingsACK) |