summaryrefslogtreecommitdiff
path: root/Source/WebCore/platform
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2019-06-10 10:48:24 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2019-06-10 10:48:47 +0300
commitcd2fc453baf21084d0fb9f5f6b203f3aac3fa2ba (patch)
tree8d12b4055e217fd284aa0cae6a7fedb06d14b986 /Source/WebCore/platform
parent3dc7d3b44fa620814acd553c1a82f020183951b3 (diff)
downloadqtwebkit-cd2fc453baf21084d0fb9f5f6b203f3aac3fa2ba.tar.gz
Import WebKit commit eb64318ce61c3d6c6bd2c52ee1df69820a19802c
Change-Id: I73331bc707a68785c44548f5d607c0e62f68e701 Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebCore/platform')
-rw-r--r--Source/WebCore/platform/network/NetworkingContext.h4
-rw-r--r--Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp5
-rw-r--r--Source/WebCore/platform/network/qt/ResourceRequestQt.cpp28
3 files changed, 18 insertions, 19 deletions
diff --git a/Source/WebCore/platform/network/NetworkingContext.h b/Source/WebCore/platform/network/NetworkingContext.h
index 3de432e42..582bca647 100644
--- a/Source/WebCore/platform/network/NetworkingContext.h
+++ b/Source/WebCore/platform/network/NetworkingContext.h
@@ -28,10 +28,6 @@
#include <wtf/SchedulePair.h>
#endif
-#if PLATFORM(QT)
-#include <qglobal.h>
-#endif
-
#if PLATFORM(COCOA)
OBJC_CLASS NSOperationQueue;
#endif
diff --git a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
index 631adf37d..0ce68838e 100644
--- a/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
+++ b/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
@@ -609,6 +609,7 @@ void QNetworkReplyHandler::sendResponseIfNeeded()
response.setHTTPHeaderField(String(pair.first.constData(), pair.first.size()), String(pair.second.constData(), pair.second.size()));
}
+ // Note: Qt sets RedirectionTargetAttribute only for 3xx responses, so Location header in 201 responce won't affect this code
QUrl redirection = m_replyWrapper->reply()->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
if (redirection.isValid()) {
redirect(response, redirection);
@@ -651,8 +652,10 @@ void QNetworkReplyHandler::redirect(ResourceResponse& response, const QUrl& redi
ASSERT(!m_queue.deferSignals());
QUrl currentUrl = m_replyWrapper->reply()->url();
+
+ // RFC7231 section 7.1.2
QUrl newUrl = currentUrl.resolved(redirection);
- if (currentUrl.hasFragment())
+ if (!newUrl.hasFragment() && currentUrl.hasFragment())
newUrl.setFragment(currentUrl.fragment());
ResourceHandleClient* client = m_resourceHandle->client();
diff --git a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp
index c54a8115b..694e2a764 100644
--- a/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp
+++ b/Source/WebCore/platform/network/qt/ResourceRequestQt.cpp
@@ -27,16 +27,20 @@
#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)
+// HTTP/2 is implemented since Qt 5.8, but various QtNetwork bugs make it unusable in browser with Qt < 5.10.1
+// We also don't enable HTTP/2 for unencrypted connections because of possible compatibility issues; it can be
+// enabled manually by user application via custom QNAM subclass
+#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 1)
+#include <QSslSocket>
#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
+// Don't enable HTTP/2 when ALPN support status is unknown
+// Before QTBUG-65903 is implemented there is no better way than to check OpenSSL version
+static bool alpnIsSupported()
+{
+ return QSslSocket::sslLibraryVersionNumber() > 0x10002000L &&
+ QSslSocket::sslLibraryVersionString().startsWith(QLatin1String("OpenSSL"));
+}
#endif
namespace WebCore {
@@ -74,15 +78,11 @@ 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"))
-#endif
- {
+ static const bool NegotiateHttp2ForHttps = alpnIsSupported();
+ if (originalUrl.protocolIs("https") && NegotiateHttp2ForHttps)
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) {