mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-31 03:50:20 -07:00
Restart idle timer on sending network response
This commit is contained in:
parent
c652123145
commit
ece92a886a
2 changed files with 15 additions and 8 deletions
|
@ -45,8 +45,18 @@ Connection::Connection(QTcpSocket *socket, IRequestHandler *requestHandler, QObj
|
||||||
, m_requestHandler(requestHandler)
|
, m_requestHandler(requestHandler)
|
||||||
{
|
{
|
||||||
m_socket->setParent(this);
|
m_socket->setParent(this);
|
||||||
|
|
||||||
|
// reset timer when there are activity
|
||||||
m_idleTimer.start();
|
m_idleTimer.start();
|
||||||
connect(m_socket, &QTcpSocket::readyRead, this, &Connection::read);
|
connect(m_socket, &QIODevice::readyRead, this, [this]()
|
||||||
|
{
|
||||||
|
m_idleTimer.start();
|
||||||
|
read();
|
||||||
|
});
|
||||||
|
connect(m_socket, &QIODevice::bytesWritten, this, [this]()
|
||||||
|
{
|
||||||
|
m_idleTimer.start();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection::~Connection()
|
Connection::~Connection()
|
||||||
|
@ -56,7 +66,6 @@ Connection::~Connection()
|
||||||
|
|
||||||
void Connection::read()
|
void Connection::read()
|
||||||
{
|
{
|
||||||
m_idleTimer.restart();
|
|
||||||
m_receivedData.append(m_socket->readAll());
|
m_receivedData.append(m_socket->readAll());
|
||||||
|
|
||||||
while (!m_receivedData.isEmpty())
|
while (!m_receivedData.isEmpty())
|
||||||
|
|
|
@ -52,11 +52,9 @@ namespace Http
|
||||||
bool hasExpired(qint64 timeout) const;
|
bool hasExpired(qint64 timeout) const;
|
||||||
bool isClosed() const;
|
bool isClosed() const;
|
||||||
|
|
||||||
private slots:
|
|
||||||
void read();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool acceptsGzipEncoding(QString codings);
|
static bool acceptsGzipEncoding(QString codings);
|
||||||
|
void read();
|
||||||
void sendResponse(const Response &response) const;
|
void sendResponse(const Response &response) const;
|
||||||
|
|
||||||
QTcpSocket *m_socket;
|
QTcpSocket *m_socket;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue