summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2024-03-21 15:56:19 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2024-04-17 20:30:36 +0200
commit28bff27b8596375c524560c386ab101da428e738 (patch)
treef2e75e62a98f49616661be47bad053fd85ff08c3 /src/network
parente88a2ed83baf1822971cff96a3195d872445b505 (diff)
QHttpNetworkConnectionPrivate: move some init logic into a function
Now we can nicely initialize it as a member-initializer. Do channels at the same time, NSDMI follows. Task-number: QTBUG-102855 Change-Id: I59c1fe044687500ed3a9d5878c6e4fc137114542 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qhttpnetworkconnection.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp
index 3f107b5a5b..24637e68c6 100644
--- a/src/network/access/qhttpnetworkconnection.cpp
+++ b/src/network/access/qhttpnetworkconnection.cpp
@@ -40,24 +40,28 @@ const int QHttpNetworkConnectionPrivate::defaultPipelineLength = 3;
// This means that there are 2 requests in flight and 2 slots free that will be re-filled.
const int QHttpNetworkConnectionPrivate::defaultRePipelineLength = 2;
+static int getPreferredActiveChannelCount(QHttpNetworkConnection::ConnectionType type,
+ int defaultValue)
+{
+ return (type == QHttpNetworkConnection::ConnectionTypeHTTP2
+ || type == QHttpNetworkConnection::ConnectionTypeHTTP2Direct)
+ ? 1
+ : defaultValue;
+}
QHttpNetworkConnectionPrivate::QHttpNetworkConnectionPrivate(quint16 connectionCount, const QString &hostName,
quint16 port, bool encrypt,
QHttpNetworkConnection::ConnectionType type)
: state(RunningState), networkLayerState(Unknown),
hostName(hostName), port(port), encrypt(encrypt), delayIpv4(true),
- channelCount(connectionCount)
+ activeChannelCount(getPreferredActiveChannelCount(type, connectionCount)),
+ channelCount(connectionCount), channels(new QHttpNetworkConnectionChannel[channelCount])
#ifndef QT_NO_NETWORKPROXY
, networkProxy(QNetworkProxy::NoProxy)
#endif
, preConnectRequests(0)
, connectionType(type)
{
- channels = new QHttpNetworkConnectionChannel[channelCount];
-
- activeChannelCount = (type == QHttpNetworkConnection::ConnectionTypeHTTP2 ||
- type == QHttpNetworkConnection::ConnectionTypeHTTP2Direct)
- ? 1 : connectionCount;
// We allocate all 6 channels even if it's an HTTP/2-enabled
// connection: in case the protocol negotiation via NPN/ALPN fails,
// we will have normally working HTTP/1.1.