Fix build with older Qt: Disable http2 for now due to Qt bug, add env var (upstream)
authorMichael Schuster <michael@schuster.ms>
Mon, 2 Mar 2020 00:47:00 +0000 (01:47 +0100)
committerMichael Schuster <michael@schuster.ms>
Mon, 2 Mar 2020 00:47:00 +0000 (01:47 +0100)
Disable http2 for now due to Qt bug but allow enabling it via env var, see: https://github.com/owncloud/client/pull/7620
  and: https://github.com/nextcloud/desktop/pull/1806
Issue: https://github.com/nextcloud/desktop/issues/1503

Co-authored-by: XNG <Milokita@users.noreply.github.com>
Co-authored-by: Hannah von Reth <hannah.vonreth@owncloud.com>
Signed-off-by: Michael Schuster <michael@schuster.ms>
src/libsync/accessmanager.cpp

index 6564ae0c860e188a0c275017498aea7306ef9d7a..8cba1a71d8da4025bdb165a34f29b24e1a1adf3f 100644 (file)
@@ -93,12 +93,19 @@ QNetworkReply *AccessManager::createRequest(QNetworkAccessManager::Operation op,
     qInfo(lcAccessManager) << op << verb << newRequest.url().toString() << "has X-Request-ID" << requestId;
     newRequest.setRawHeader("X-Request-ID", requestId);
 
+#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 4)
+    // only enable HTTP2 with Qt 5.9.4 because old Qt have too many bugs (e.g. QTBUG-64359 is fixed in >= Qt 5.9.4)
 
-    // Disable http2 for now due to Qt bug
+    /* Disable http2 for now due to Qt bug but allow enabling it via env var, see: https://github.com/owncloud/client/pull/7620
+     *   and: https://github.com/nextcloud/desktop/pull/1806
+     * Issue: https://github.com/nextcloud/desktop/issues/1503
+     */
     if (newRequest.url().scheme() == "https") { // Not for "http": QTBUG-61397
-        newRequest.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, false);
-    }
+        static const bool http2EnabledEnv = qEnvironmentVariableIntValue("OWNCLOUD_HTTP2_ENABLED") == 1;
 
+        newRequest.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, http2EnabledEnv);
+    }
+#endif
 
     return QNetworkAccessManager::createRequest(op, newRequest, outgoingData);
 }