diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-09-10 13:08:05 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-09-11 09:25:42 +0200 |
commit | 5909e6d0d10de3e1370b3ea0bc596f580101e3b4 (patch) | |
tree | 6acc39b8ea0165562d480f1c54608c6c4ae9f865 /Source/WebCore/platform/network/qt/ResourceRequestQt.cpp | |
parent | beaeeb99881184fd368c121fcbb1a31c78b794a3 (diff) | |
parent | 81cbb264cb9446c4408124d50aeff50164ad0ab4 (diff) | |
download | qtwebkit-5909e6d0d10de3e1370b3ea0bc596f580101e3b4.tar.gz |
Merge "Merge remote-tracking branch 'origin/5.212' into dev"
Diffstat (limited to 'Source/WebCore/platform/network/qt/ResourceRequestQt.cpp')
-rw-r--r-- | Source/WebCore/platform/network/qt/ResourceRequestQt.cpp | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp index c54a8115b..310738449 100644 --- a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp +++ b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp @@ -27,17 +27,12 @@ #include <QNetworkRequest> #include <QUrl> -// HTTP/2 is implemented since Qt 5.8, but QTBUG-64359 makes it unusable in browser -#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 4) -#define USE_HTTP2 1 -#endif - -// HTTP2AllowedAttribute enforces HTTP/2 instead of negotiating, see QTBUG-61397 -#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) -#define HTTP2_IS_BUGGY_WITHOUT_HTTPS 1 -#else -#define HTTP2_IS_BUGGY_WITHOUT_HTTPS 0 +#if USE(HTTP2) +#include <QSslSocket> +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +#include <QHttp2Configuration> #endif +#endif // USE(HTTP2) namespace WebCore { @@ -66,6 +61,25 @@ static inline QByteArray stringToByteArray(const String& string) return QString(string).toLatin1(); } +#if USE(HTTP2) +bool ResourceRequest::alpnIsSupported() +{ + // Before QTBUG-65903 is implemented there is no better way than to check OpenSSL version + return QSslSocket::sslLibraryVersionNumber() > 0x10002000L && + QSslSocket::sslLibraryVersionString().startsWith(QLatin1String("OpenSSL")); +} + +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) +static QHttp2Configuration createHttp2Configuration() +{ + QHttp2Configuration params; + params.setServerPushEnabled(true); + return params; +} +#endif + +#endif + QNetworkRequest ResourceRequest::toNetworkRequest(NetworkingContext *context) const { QNetworkRequest request; @@ -74,15 +88,16 @@ QNetworkRequest ResourceRequest::toNetworkRequest(NetworkingContext *context) co request.setOriginatingObject(context ? context->originatingObject() : 0); #if USE(HTTP2) -#if HTTP2_IS_BUGGY_WITHOUT_HTTPS - if (originalUrl.protocolIs("https")) + static const bool NegotiateHttp2ForHttps = alpnIsSupported(); + if (originalUrl.protocolIs("https") && NegotiateHttp2ForHttps) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + static const auto params = createHttp2Configuration(); + request.setHttp2Configuration(params); #endif - { request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, true); } #endif // USE(HTTP2) - const HTTPHeaderMap &headers = httpHeaderFields(); for (HTTPHeaderMap::const_iterator it = headers.begin(), end = headers.end(); it != end; ++it) { |