summaryrefslogtreecommitdiffstats
path: root/src/network/access/qhttpnetworkconnectionchannel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/access/qhttpnetworkconnectionchannel.cpp')
-rw-r--r--src/network/access/qhttpnetworkconnectionchannel.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp
index 6fe1ce38a61..9f59d11375b 100644
--- a/src/network/access/qhttpnetworkconnectionchannel.cpp
+++ b/src/network/access/qhttpnetworkconnectionchannel.cpp
@@ -5,7 +5,6 @@
#include "qhttpnetworkconnectionchannel_p.h"
#include "qhttpnetworkconnection_p.h"
-#include "qhttp2configuration.h"
#include "private/qnoncontiguousbytedevice_p.h"
#include <qdebug.h>
@@ -34,6 +33,12 @@ QT_BEGIN_NAMESPACE
// connection times out)
// We use 3 because we can get a _q_error 3 times depending on the timing:
static const int reconnectAttemptsDefault = 3;
+static const char keepAliveIdleOption[] = "QT_QNAM_TCP_KEEPIDLE";
+static const char keepAliveIntervalOption[] = "QT_QNAM_TCP_KEEPINTVL";
+static const char keepAliveCountOption[] = "QT_QNAM_TCP_KEEPCNT";
+static const int TCP_KEEPIDLE_DEF = 60;
+static const int TCP_KEEPINTVL_DEF = 10;
+static const int TCP_KEEPCNT_DEF = 5;
QHttpNetworkConnectionChannel::QHttpNetworkConnectionChannel()
: socket(nullptr)
@@ -914,6 +919,13 @@ void QHttpNetworkConnectionChannel::_q_connected_abstract_socket(QAbstractSocket
// not sure yet if it helps, but it makes sense
absSocket->setSocketOption(QAbstractSocket::KeepAliveOption, 1);
+ int kaIdleOption = qEnvironmentVariableIntegerValue(keepAliveIdleOption).value_or(TCP_KEEPIDLE_DEF);
+ int kaIntervalOption = qEnvironmentVariableIntegerValue(keepAliveIntervalOption).value_or(TCP_KEEPINTVL_DEF);
+ int kaCountOption = qEnvironmentVariableIntegerValue(keepAliveCountOption).value_or(TCP_KEEPCNT_DEF);
+ absSocket->setSocketOption(QAbstractSocket::KeepAliveIdleOption, kaIdleOption);
+ absSocket->setSocketOption(QAbstractSocket::KeepAliveIntervalOption, kaIntervalOption);
+ absSocket->setSocketOption(QAbstractSocket::KeepAliveCountOption, kaCountOption);
+
pipeliningSupported = QHttpNetworkConnectionChannel::PipeliningSupportUnknown;
// ### FIXME: if the server closes the connection unexpectedly, we shouldn't send the same broken request again!