AccessManager: Disable HTTP/2 without TLS

Qt would otherwise still try to do HTTP/2 connection even over "http://".
And that does not work with server that does not support it
This commit is contained in:
Olivier Goffart 2017-06-13 15:29:01 +02:00 committed by Olivier Goffart
parent 520923b5a7
commit b1363d1a79

View file

@ -94,8 +94,11 @@ QNetworkReply *AccessManager::createRequest(QNetworkAccessManager::Operation op,
newRequest.setRawHeader("X-Request-ID", requestId);
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
// only enable HTTP2 with Qt 5.9 because Qt 5.8.0 has too many bugs (only use one connection if the server does not support HTTP2)
newRequest.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, true);
// only enable HTTP2 with Qt 5.9 because Qt 5.8.0 has too many bugs
// (only use one connection if the server does not support HTTP2)
if (newRequest.url().scheme() == "https") { // Not for "http": QTBUG-61397
newRequest.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, true);
}
#endif
return QNetworkAccessManager::createRequest(op, newRequest, outgoingData);