Move away from recently deprecated HTTP2 attributes

Amends f59f67287fa17e8d4edf6a231c010f768d1b76e8

Change-Id: I74045c558e9d20f9f45f150a91f181a04e9b8c69
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Mårten Nordheim 2019-10-01 12:13:47 +02:00
parent 8791a8398a
commit 6e203824a2
4 changed files with 15 additions and 15 deletions

View File

@ -1240,7 +1240,7 @@ void QNetworkAccessManager::connectToHostEncrypted(const QString &hostName, quin
// There is no way to enable SPDY/HTTP2 via a request, so we need to check // There is no way to enable SPDY/HTTP2 via a request, so we need to check
// the ssl configuration whether SPDY/HTTP2 is allowed here. // the ssl configuration whether SPDY/HTTP2 is allowed here.
if (sslConfiguration.allowedNextProtocols().contains(QSslConfiguration::ALPNProtocolHTTP2)) if (sslConfiguration.allowedNextProtocols().contains(QSslConfiguration::ALPNProtocolHTTP2))
request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, true); request.setAttribute(QNetworkRequest::Http2AllowedAttribute, true);
else if (sslConfiguration.allowedNextProtocols().contains(QSslConfiguration::NextProtocolSpdy3_0)) else if (sslConfiguration.allowedNextProtocols().contains(QSslConfiguration::NextProtocolSpdy3_0))
request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true); request.setAttribute(QNetworkRequest::SpdyAllowedAttribute, true);

View File

@ -777,7 +777,7 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq
if (request.attribute(QNetworkRequest::SpdyAllowedAttribute).toBool()) if (request.attribute(QNetworkRequest::SpdyAllowedAttribute).toBool())
httpRequest.setSPDYAllowed(true); httpRequest.setSPDYAllowed(true);
if (request.attribute(QNetworkRequest::HTTP2AllowedAttribute).toBool()) if (request.attribute(QNetworkRequest::Http2AllowedAttribute).toBool())
httpRequest.setHTTP2Allowed(true); httpRequest.setHTTP2Allowed(true);
if (request.attribute(QNetworkRequest::Http2DirectAttribute).toBool()) { if (request.attribute(QNetworkRequest::Http2DirectAttribute).toBool()) {
@ -1280,15 +1280,15 @@ void QNetworkReplyHttpImplPrivate::replyDownloadMetaData(const QList<QPair<QByte
} }
q->setAttribute(QNetworkRequest::HttpPipeliningWasUsedAttribute, pu); q->setAttribute(QNetworkRequest::HttpPipeliningWasUsedAttribute, pu);
const QVariant http2Allowed = request.attribute(QNetworkRequest::HTTP2AllowedAttribute); const QVariant http2Allowed = request.attribute(QNetworkRequest::Http2AllowedAttribute);
const QVariant http2Direct = request.attribute(QNetworkRequest::Http2DirectAttribute); const QVariant http2Direct = request.attribute(QNetworkRequest::Http2DirectAttribute);
if ((http2Allowed.isValid() && http2Allowed.toBool()) if ((http2Allowed.isValid() && http2Allowed.toBool())
|| (http2Direct.isValid() && http2Direct.toBool())) { || (http2Direct.isValid() && http2Direct.toBool())) {
q->setAttribute(QNetworkRequest::HTTP2WasUsedAttribute, spdyWasUsed); q->setAttribute(QNetworkRequest::Http2WasUsedAttribute, spdyWasUsed);
q->setAttribute(QNetworkRequest::SpdyWasUsedAttribute, false); q->setAttribute(QNetworkRequest::SpdyWasUsedAttribute, false);
} else { } else {
q->setAttribute(QNetworkRequest::SpdyWasUsedAttribute, spdyWasUsed); q->setAttribute(QNetworkRequest::SpdyWasUsedAttribute, spdyWasUsed);
q->setAttribute(QNetworkRequest::HTTP2WasUsedAttribute, false); q->setAttribute(QNetworkRequest::Http2WasUsedAttribute, false);
} }
// reconstruct the HTTP header // reconstruct the HTTP header

View File

@ -336,7 +336,7 @@ QT_BEGIN_NAMESPACE
server supports HTTP/2. The attribute works with SSL or 'cleartext' server supports HTTP/2. The attribute works with SSL or 'cleartext'
HTTP/2. If a server turns out to not support HTTP/2, when HTTP/2 direct HTTP/2. If a server turns out to not support HTTP/2, when HTTP/2 direct
was specified, QNetworkAccessManager gives up, without attempting to was specified, QNetworkAccessManager gives up, without attempting to
fall back to HTTP/1.1. If both HTTP2AllowedAttribute and fall back to HTTP/1.1. If both Http2AllowedAttribute and
Http2DirectAttribute are set, Http2DirectAttribute takes priority. Http2DirectAttribute are set, Http2DirectAttribute takes priority.
(This value was introduced in 5.11.) (This value was introduced in 5.11.)

View File

@ -219,12 +219,12 @@ void tst_Http2::singleRequest_data()
// 'Clear text' that should always work, either via the protocol upgrade // 'Clear text' that should always work, either via the protocol upgrade
// or as direct. // or as direct.
QTest::addRow("h2c-upgrade") << QNetworkRequest::HTTP2AllowedAttribute << H2Type::h2c; QTest::addRow("h2c-upgrade") << QNetworkRequest::Http2AllowedAttribute << H2Type::h2c;
QTest::addRow("h2c-direct") << QNetworkRequest::Http2DirectAttribute << H2Type::h2cDirect; QTest::addRow("h2c-direct") << QNetworkRequest::Http2DirectAttribute << H2Type::h2cDirect;
if (!clearTextHTTP2) { if (!clearTextHTTP2) {
// Qt with TLS where TLS-backend supports ALPN. // Qt with TLS where TLS-backend supports ALPN.
QTest::addRow("h2-ALPN") << QNetworkRequest::HTTP2AllowedAttribute << H2Type::h2Alpn; QTest::addRow("h2-ALPN") << QNetworkRequest::Http2AllowedAttribute << H2Type::h2Alpn;
} }
#if QT_CONFIG(ssl) #if QT_CONFIG(ssl)
@ -429,7 +429,7 @@ void tst_Http2::pushPromise()
url.setPath("/index.html"); url.setPath("/index.html");
QNetworkRequest request(url); QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true)); request.setAttribute(QNetworkRequest::Http2AllowedAttribute, QVariant(true));
request.setHttp2Configuration(params); request.setHttp2Configuration(params);
auto reply = manager->get(request); auto reply = manager->get(request);
@ -455,7 +455,7 @@ void tst_Http2::pushPromise()
url.setPath("/script.js"); url.setPath("/script.js");
QNetworkRequest promisedRequest(url); QNetworkRequest promisedRequest(url);
promisedRequest.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true)); promisedRequest.setAttribute(QNetworkRequest::Http2AllowedAttribute, QVariant(true));
reply = manager->get(promisedRequest); reply = manager->get(promisedRequest);
connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished); connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished);
reply->ignoreSslErrors(); reply->ignoreSslErrors();
@ -509,7 +509,7 @@ void tst_Http2::goaway()
for (int i = 0; i < nRequests; ++i) { for (int i = 0; i < nRequests; ++i) {
url.setPath(QString("/%1").arg(i)); url.setPath(QString("/%1").arg(i));
QNetworkRequest request(url); QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true)); request.setAttribute(QNetworkRequest::Http2AllowedAttribute, QVariant(true));
replies[i] = manager->get(request); replies[i] = manager->get(request);
QCOMPARE(replies[i]->error(), QNetworkReply::NoError); QCOMPARE(replies[i]->error(), QNetworkReply::NoError);
void (QNetworkReply::*errorSignal)(QNetworkReply::NetworkError) = void (QNetworkReply::*errorSignal)(QNetworkReply::NetworkError) =
@ -582,7 +582,7 @@ void tst_Http2::connectToHost_data()
#if QT_CONFIG(ssl) #if QT_CONFIG(ssl)
QTest::addRow("encrypted-h2-direct") << QNetworkRequest::Http2DirectAttribute << H2Type::h2Direct; QTest::addRow("encrypted-h2-direct") << QNetworkRequest::Http2DirectAttribute << H2Type::h2Direct;
if (!clearTextHTTP2) if (!clearTextHTTP2)
QTest::addRow("encrypted-h2-ALPN") << QNetworkRequest::HTTP2AllowedAttribute << H2Type::h2Alpn; QTest::addRow("encrypted-h2-ALPN") << QNetworkRequest::Http2AllowedAttribute << H2Type::h2Alpn;
#endif // QT_CONFIG(ssl) #endif // QT_CONFIG(ssl)
// This works for all configurations, tests 'preconnect-http' scheme: // This works for all configurations, tests 'preconnect-http' scheme:
// h2 with protocol upgrade is not working for now (the logic is a bit // h2 with protocol upgrade is not working for now (the logic is a bit
@ -725,7 +725,7 @@ void tst_Http2::maxFrameSize()
#endif // QT_CONFIG(securetransport) #endif // QT_CONFIG(securetransport)
auto connectionType = H2Type::h2Alpn; auto connectionType = H2Type::h2Alpn;
auto attribute = QNetworkRequest::HTTP2AllowedAttribute; auto attribute = QNetworkRequest::Http2AllowedAttribute;
if (clearTextHTTP2) { if (clearTextHTTP2) {
connectionType = H2Type::h2Direct; connectionType = H2Type::h2Direct;
attribute = QNetworkRequest::Http2DirectAttribute; attribute = QNetworkRequest::Http2DirectAttribute;
@ -825,7 +825,7 @@ void tst_Http2::sendRequest(int streamNumber,
url.setPath(QString("/stream%1.html").arg(streamNumber)); url.setPath(QString("/stream%1.html").arg(streamNumber));
QNetworkRequest request(url); QNetworkRequest request(url);
request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true)); request.setAttribute(QNetworkRequest::Http2AllowedAttribute, QVariant(true));
request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, QVariant(true)); request.setAttribute(QNetworkRequest::FollowRedirectsAttribute, QVariant(true));
request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain")); request.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain"));
request.setPriority(priority); request.setPriority(priority);
@ -932,7 +932,7 @@ void tst_Http2::replyFinished()
QCOMPARE(reply->error(), QNetworkReply::NoError); QCOMPARE(reply->error(), QNetworkReply::NoError);
const QVariant http2Used(reply->attribute(QNetworkRequest::HTTP2WasUsedAttribute)); const QVariant http2Used(reply->attribute(QNetworkRequest::Http2WasUsedAttribute));
if (!http2Used.isValid() || !http2Used.toBool()) if (!http2Used.isValid() || !http2Used.toBool())
stopEventLoop(); stopEventLoop();