summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/network/access/qhttpnetworkrequest.cpp10
-rw-r--r--src/network/access/qhttpnetworkrequest_p.h3
-rw-r--r--src/network/access/qhttpthreaddelegate.cpp6
3 files changed, 19 insertions, 0 deletions
diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp
index f370445059..f419ee2673 100644
--- a/src/network/access/qhttpnetworkrequest.cpp
+++ b/src/network/access/qhttpnetworkrequest.cpp
@@ -365,6 +365,16 @@ void QHttpNetworkRequest::setHTTP2Direct(bool b)
d->http2Direct = b;
}
+bool QHttpNetworkRequest::isH2cAllowed() const
+{
+ return qEnvironmentVariableIsSet("QT_NETWORK_H2C_ALLOWED");
+}
+
+void QHttpNetworkRequest::setH2cAllowed(bool b)
+{
+ Q_UNUSED(b);
+}
+
bool QHttpNetworkRequest::withCredentials() const
{
return d->withCredentials;
diff --git a/src/network/access/qhttpnetworkrequest_p.h b/src/network/access/qhttpnetworkrequest_p.h
index 50fdd64290..f4c1d7fb8c 100644
--- a/src/network/access/qhttpnetworkrequest_p.h
+++ b/src/network/access/qhttpnetworkrequest_p.h
@@ -125,6 +125,9 @@ public:
bool isHTTP2Direct() const;
void setHTTP2Direct(bool b);
+ bool isH2cAllowed() const;
+ void setH2cAllowed(bool b);
+
bool withCredentials() const;
void setWithCredentials(bool b);
diff --git a/src/network/access/qhttpthreaddelegate.cpp b/src/network/access/qhttpthreaddelegate.cpp
index 50a14b6258..243492d466 100644
--- a/src/network/access/qhttpthreaddelegate.cpp
+++ b/src/network/access/qhttpthreaddelegate.cpp
@@ -290,6 +290,12 @@ void QHttpThreadDelegate::startRequest()
connectionType = QHttpNetworkConnection::ConnectionTypeHTTP2Direct;
}
+ // Use HTTP/1.1 if h2c is not allowed and we would otherwise choose to use it
+ if (!ssl && connectionType == QHttpNetworkConnection::ConnectionTypeHTTP2
+ && !httpRequest.isH2cAllowed()) {
+ connectionType = QHttpNetworkConnection::ConnectionTypeHTTP;
+ }
+
#if QT_CONFIG(ssl)
// See qnetworkreplyhttpimpl, delegate's initialization code.
Q_ASSERT(!ssl || incomingSslConfiguration.data());