QNAM: Enable HTTP/2 by default
It has been in Qt for some years now and 6.0 marks a good point to enable it by default. The exception is connectToHostEncrypted where we still require the users to enable it explicitly since there's no logical way to disable it. [ChangeLog][QtNetwork][QNetworkAccessManager] HTTP/2 is now enabled by default. Fixes: QTBUG-85902 Change-Id: Ia029a045727cc593d77df9eb3a5888522ad19199 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
00d9a0ea8e
commit
8a3847aab9
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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'
|
||||
|
@ -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.
|
||||
|
@ -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()));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user