summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2021-06-24 17:32:24 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-06-24 19:51:51 +0000
commit517d42e4ce0f55a0517c57590a39121c8e113a03 (patch)
treeff393f7a431c2028ac957184c79e32ac4ad8a2b9
parentc905f771c1c578488a7c26de1ccff6ce784e5bfb (diff)
tst_http2: use the supportedFeatures() instead of macros
With the recent change, 'system' headers gone: not in the test code anymore, so, for example OPENSSL_VERSION_NUMBER is undefined, making the test to select a wrong code-path - 'h2c', instead of encrypted h2. Change-Id: I3b201e21fac56875c9045c7463e2ae69af4c6470 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> (cherry picked from commit 13ce568b768bbdaa19adc4207a04b74414c14d62) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/tls/openssl/qtlsbackend_openssl.cpp4
-rw-r--r--tests/auto/network/access/http2/tst_http2.cpp24
2 files changed, 18 insertions, 10 deletions
diff --git a/src/plugins/tls/openssl/qtlsbackend_openssl.cpp b/src/plugins/tls/openssl/qtlsbackend_openssl.cpp
index 544ce1bcef..7711f66bb5 100644
--- a/src/plugins/tls/openssl/qtlsbackend_openssl.cpp
+++ b/src/plugins/tls/openssl/qtlsbackend_openssl.cpp
@@ -318,8 +318,12 @@ QList<QSsl::SupportedFeature> QTlsBackendOpenSSL::supportedFeatures() const
QList<QSsl::SupportedFeature> features;
features << QSsl::SupportedFeature::CertificateVerification;
+
+#if !defined(OPENSSL_NO_TLSEXT)
features << QSsl::SupportedFeature::ClientSideAlpn;
features << QSsl::SupportedFeature::ServerSideAlpn;
+#endif // !OPENSSL_NO_TLSEXT
+
features << QSsl::SupportedFeature::Ocsp;
features << QSsl::SupportedFeature::Psk;
features << QSsl::SupportedFeature::SessionTicket;
diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp
index af3b6ba419..230c371ac9 100644
--- a/tests/auto/network/access/http2/tst_http2.cpp
+++ b/tests/auto/network/access/http2/tst_http2.cpp
@@ -26,6 +26,8 @@
**
****************************************************************************/
+#include <QtNetwork/qtnetworkglobal.h>
+
#include <QTest>
#include <QTestEventLoop>
#include <QScopeGuard>
@@ -40,6 +42,10 @@
#include <QtNetwork/qnetworkrequest.h>
#include <QtNetwork/qnetworkreply.h>
+#if QT_CONFIG(ssl)
+#include <QtNetwork/qsslsocket.h>
+#endif
+
#include <QtCore/qglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qthread.h>
@@ -51,16 +57,6 @@
#include <QtTest/private/qemulationdetector_p.h>
-#if (!defined(QT_NO_OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(OPENSSL_NO_TLSEXT)) \
- || QT_CONFIG(schannel)
-// HTTP/2 over TLS requires ALPN/NPN to negotiate the protocol version.
-const bool clearTextHTTP2 = false;
-#else
-// No ALPN/NPN support to negotiate HTTP/2, we'll use cleartext 'h2c' with
-// a protocol upgrade procedure.
-const bool clearTextHTTP2 = true;
-#endif
-
Q_DECLARE_METATYPE(H2Type)
Q_DECLARE_METATYPE(QNetworkRequest::Attribute)
@@ -184,6 +180,8 @@ struct ServerDeleter
}
};
+bool clearTextHTTP2 = false;
+
using ServerPtr = QScopedPointer<Http2Server, ServerDeleter>;
H2Type defaultConnectionType()
@@ -196,6 +194,12 @@ H2Type defaultConnectionType()
tst_Http2::tst_Http2()
: workerThread(new QThread)
{
+#if QT_CONFIG(ssl)
+ const auto features = QSslSocket::supportedFeatures();
+ clearTextHTTP2 = !features.contains(QSsl::SupportedFeature::ServerSideAlpn);
+#else
+ clearTextHTTP2 = true;
+#endif
workerThread->start();
}