summaryrefslogtreecommitdiffstats
path: root/src/network/access/qhttpthreaddelegate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/access/qhttpthreaddelegate.cpp')
-rw-r--r--src/network/access/qhttpthreaddelegate.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp
index 6fb4710d77..acc551a7c9 100644
--- a/src/network/access/qhttpthreaddelegate.cpp
+++ b/src/network/access/qhttpthreaddelegate.cpp
@@ -128,7 +128,8 @@ static QByteArray makeCacheKey(QUrl &url, QNetworkProxy *proxy, const QString &p
QString result;
QUrl copy = url;
QString scheme = copy.scheme();
- bool isEncrypted = scheme == QLatin1String("https");
+ bool isEncrypted = scheme == QLatin1String("https")
+ || scheme == QLatin1String("preconnect-https");
copy.setPort(copy.port(isEncrypted ? 443 : 80));
if (scheme == QLatin1String("preconnect-http")) {
copy.setScheme(QLatin1String("http"));
@@ -296,17 +297,29 @@ void QHttpThreadDelegate::startRequest()
connectionType = QHttpNetworkConnection::ConnectionTypeHTTP2Direct;
}
+ const bool isH2 = httpRequest.isHTTP2Allowed() || httpRequest.isHTTP2Direct();
+ if (isH2) {
+#if QT_CONFIG(ssl)
+ if (ssl) {
+ if (!httpRequest.isHTTP2Direct()) {
+ QList<QByteArray> protocols;
+ protocols << QSslConfiguration::ALPNProtocolHTTP2
+ << QSslConfiguration::NextProtocolHttp1_1;
+ incomingSslConfiguration->setAllowedNextProtocols(protocols);
+ }
+ urlCopy.setScheme(QStringLiteral("h2s"));
+ } else
+#endif // QT_CONFIG(ssl)
+ {
+ urlCopy.setScheme(QStringLiteral("h2"));
+ }
+ }
+
#ifndef QT_NO_SSL
if (ssl && !incomingSslConfiguration.data())
incomingSslConfiguration.reset(new QSslConfiguration);
- if (httpRequest.isHTTP2Allowed() && ssl) {
- // With HTTP2Direct we do not try any protocol negotiation.
- QList<QByteArray> protocols;
- protocols << QSslConfiguration::ALPNProtocolHTTP2
- << QSslConfiguration::NextProtocolHttp1_1;
- incomingSslConfiguration->setAllowedNextProtocols(protocols);
- } else if (httpRequest.isSPDYAllowed() && ssl) {
+ if (!isH2 && httpRequest.isSPDYAllowed() && ssl) {
connectionType = QHttpNetworkConnection::ConnectionTypeSPDY;
urlCopy.setScheme(QStringLiteral("spdy")); // to differentiate SPDY requests from HTTPS requests
QList<QByteArray> nextProtocols;
@@ -323,12 +336,11 @@ void QHttpThreadDelegate::startRequest()
cacheKey = makeCacheKey(urlCopy, &cacheProxy, httpRequest.peerVerifyName());
else
#endif
- cacheKey = makeCacheKey(urlCopy, 0, httpRequest.peerVerifyName());
-
+ cacheKey = makeCacheKey(urlCopy, nullptr, httpRequest.peerVerifyName());
// the http object is actually a QHttpNetworkConnection
httpConnection = static_cast<QNetworkAccessCachedHttpConnection *>(connections.localData()->requestEntryNow(cacheKey));
- if (httpConnection == 0) {
+ if (!httpConnection) {
// no entry in cache; create an object
// the http object is actually a QHttpNetworkConnection
#ifdef QT_NO_BEARERMANAGEMENT
@@ -358,7 +370,7 @@ void QHttpThreadDelegate::startRequest()
connections.localData()->addEntry(cacheKey, httpConnection);
} else {
if (httpRequest.withCredentials()) {
- QNetworkAuthenticationCredential credential = authenticationManager->fetchCachedCredentials(httpRequest.url(), 0);
+ QNetworkAuthenticationCredential credential = authenticationManager->fetchCachedCredentials(httpRequest.url(), nullptr);
if (!credential.user.isEmpty() && !credential.password.isEmpty()) {
QAuthenticator auth;
auth.setUser(credential.user);