AccessManager: Disable HTTP/2 without TLS
authorOlivier Goffart <ogoffart@woboq.com>
Tue, 13 Jun 2017 13:29:01 +0000 (15:29 +0200)
committerOlivier Goffart <olivier@woboq.com>
Mon, 17 Jul 2017 06:20:17 +0000 (08:20 +0200)
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

src/libsync/accessmanager.cpp

index e9f485d93c830b6d4f63ae124681a6fdb37374c4..fb131b02c212795ede4939acfc1c5419edbae99f 100644 (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);