diff options
-rw-r--r-- | src/network/access/qhttpnetworkrequest.cpp | 2 | ||||
-rw-r--r-- | src/network/access/qnetworkaccessmanager.cpp | 20 | ||||
-rw-r--r-- | src/network/access/qnetworkreplyhttpimpl.cpp | 6 | ||||
-rw-r--r-- | src/network/access/qnetworkrequest.cpp | 2 | ||||
-rw-r--r-- | tests/manual/qnetworkreply/main.cpp | 1 |
5 files changed, 16 insertions, 15 deletions
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp index 185435a1f1..7ef033047e 100644 --- a/src/network/access/qhttpnetworkrequest.cpp +++ b/src/network/access/qhttpnetworkrequest.cpp @@ -45,7 +45,7 @@ QT_BEGIN_NAMESPACE QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op, QHttpNetworkRequest::Priority pri, const QUrl &newUrl) : QHttpNetworkHeaderPrivate(newUrl), operation(op), priority(pri), uploadByteDevice(nullptr), - autoDecompress(false), pipeliningAllowed(false), http2Allowed(false), + autoDecompress(false), pipeliningAllowed(false), http2Allowed(true), http2Direct(false), withCredentials(true), preConnect(false), redirectCount(0), redirectPolicy(QNetworkRequest::ManualRedirectPolicy) { diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index 4642700887..b82864c52e 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -931,9 +931,9 @@ QNetworkReply *QNetworkAccessManager::deleteResource(const QNetworkRequest &requ \a sslConfiguration. This function is useful to complete the TCP and SSL handshake to a host before the HTTPS request is made, resulting in a lower network latency. - \note Preconnecting a SPDY connection can be done by calling setAllowedNextProtocols() - on \a sslConfiguration with QSslConfiguration::NextProtocolSpdy3_0 contained in - the list of allowed protocols. When using SPDY, one single connection per host is + \note Preconnecting a HTTP/2 connection can be done by calling setAllowedNextProtocols() + on \a sslConfiguration with QSslConfiguration::ALPNProtocolHTTP2 contained in + the list of allowed protocols. When using HTTP/2, one single connection per host is enough, i.e. calling this method multiple times per host will not result in faster network transactions. @@ -957,9 +957,9 @@ void QNetworkAccessManager::connectToHostEncrypted(const QString &hostName, quin validation. This function is useful to complete the TCP and SSL handshake to a host before the HTTPS request is made, resulting in a lower network latency. - \note Preconnecting a SPDY connection can be done by calling setAllowedNextProtocols() - on \a sslConfiguration with QSslConfiguration::NextProtocolSpdy3_0 contained in - the list of allowed protocols. When using SPDY, one single connection per host is + \note Preconnecting a HTTP/2 connection can be done by calling setAllowedNextProtocols() + on \a sslConfiguration with QSslConfiguration::ALPNProtocolHTTP2 contained in + the list of allowed protocols. When using HTTP/2, one single connection per host is enough, i.e. calling this method multiple times per host will not result in faster network transactions. @@ -980,10 +980,10 @@ void QNetworkAccessManager::connectToHostEncrypted(const QString &hostName, quin if (sslConfiguration != QSslConfiguration::defaultConfiguration()) request.setSslConfiguration(sslConfiguration); - // There is no way to enable HTTP2 via a request, so we need to check - // the ssl configuration whether HTTP2 is allowed here. - if (sslConfiguration.allowedNextProtocols().contains(QSslConfiguration::ALPNProtocolHTTP2)) - request.setAttribute(QNetworkRequest::Http2AllowedAttribute, true); + // There is no way to enable HTTP2 via a request after having established the connection, + // so we need to check the ssl configuration whether HTTP2 is allowed here. + if (!sslConfiguration.allowedNextProtocols().contains(QSslConfiguration::ALPNProtocolHTTP2)) + request.setAttribute(QNetworkRequest::Http2AllowedAttribute, false); request.setPeerVerifyName(peerName); get(request); diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp index bdb81ee0b1..5ba11333bf 100644 --- a/src/network/access/qnetworkreplyhttpimpl.cpp +++ b/src/network/access/qnetworkreplyhttpimpl.cpp @@ -755,8 +755,10 @@ void QNetworkReplyHttpImplPrivate::postRequest(const QNetworkRequest &newHttpReq if (newHttpRequest.attribute(QNetworkRequest::HttpPipeliningAllowedAttribute).toBool()) httpRequest.setPipeliningAllowed(true); - if (request.attribute(QNetworkRequest::Http2AllowedAttribute).toBool()) - httpRequest.setHTTP2Allowed(true); + if (auto allowed = request.attribute(QNetworkRequest::Http2AllowedAttribute); + allowed.isValid() && allowed.canConvert<bool>()) { + httpRequest.setHTTP2Allowed(allowed.value<bool>()); + } if (request.attribute(QNetworkRequest::Http2DirectAttribute).toBool()) { // Intentionally mutually exclusive - cannot be both direct and 'allowed' diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index 03a7f0b176..a1e17834c0 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -269,7 +269,7 @@ QT_BEGIN_NAMESPACE to different policies. \value Http2AllowedAttribute - Requests only, type: QMetaType::Bool (default: false) + Requests only, type: QMetaType::Bool (default: true) Indicates whether the QNetworkAccessManager code is allowed to use HTTP/2 with this request. This applies to SSL requests or 'cleartext' HTTP/2. diff --git a/tests/manual/qnetworkreply/main.cpp b/tests/manual/qnetworkreply/main.cpp index 8cf725dbd3..4ecb4bc728 100644 --- a/tests/manual/qnetworkreply/main.cpp +++ b/tests/manual/qnetworkreply/main.cpp @@ -386,7 +386,6 @@ void tst_qnetworkreply::npnWithEmptyList() // QTBUG-40714 QUrl url(QStringLiteral("https://www.ossifrage.net/")); QNetworkRequest request(url); - request.setAttribute(QNetworkRequest::Http2AllowedAttribute, QVariant(true)); QNetworkReply *reply = m_manager.get(request); QObject::connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop())); |