Skip to content

Commit 81e2a7b

Browse files
committed
check for open connection
1 parent 5ff7ad7 commit 81e2a7b

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/qhttpconnection.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ void QHttpConnection::waitForBytesWritten()
126126
m_socket->waitForBytesWritten();
127127
}
128128

129+
book QHttpConnection::isOpen()
130+
{
131+
return m_socket->isOpen();
132+
}
133+
129134
void QHttpConnection::responseDone()
130135
{
131136
QHttpResponse *response = qobject_cast<QHttpResponse *>(QObject::sender());

src/qhttpconnection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class QHTTPSERVER_API QHttpConnection : public QObject
4141
void write(const QByteArray &data);
4242
void flush();
4343
void waitForBytesWritten();
44+
bool isOpen();
4445

4546
Q_SIGNALS:
4647
void newRequest(QHttpRequest *, QHttpResponse *);

src/qhttpresponse.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ void QHttpResponse::waitForBytesWritten()
171171
m_connection->waitForBytesWritten();
172172
}
173173

174+
bool QHttpResponse::isOpen()
175+
{
176+
return m_connection->isOpen();
177+
}
178+
174179
void QHttpResponse::end(const QByteArray &data)
175180
{
176181
if (m_finished) {

src/qhttpresponse.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ public Q_SLOTS:
121121
/** @note writeHead() must be called before this function. */
122122
void waitForBytesWritten();
123123

124+
/// Check if connection is open to allow transmition
125+
bool isOpen();
126+
124127
/// End/finish the response.
125128
/** Data will be flushed to the underlying socket
126129
and the connection itself will be closed if

0 commit comments

Comments
 (0)