diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/socket/qhttpsocketengine.cpp | 25 | ||||
-rw-r--r-- | src/network/socket/qhttpsocketengine_p.h | 2 |
2 files changed, 16 insertions, 11 deletions
diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 07d24dd91b9..c3399122408 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -329,11 +329,7 @@ bool QHttpSocketEngine::waitForRead(QDeadlineTimer deadline, bool *timedOut) } } - // If we're not connected yet, wait until we are, or until an error - // occurs. - while (d->state != Connected && d->socket->waitForReadyRead(deadline.remainingTime())) { - // Loop while the protocol handshake is taking place. - } + waitForProtocolHandshake(deadline); // Report any error that may occur. if (d->state != Connected) { @@ -361,12 +357,7 @@ bool QHttpSocketEngine::waitForWrite(QDeadlineTimer deadline, bool *timedOut) return true; } - // If we're not connected yet, wait until we are, and until bytes have - // been received (i.e., the socket has connected, we have sent the - // greeting, and then received the response). - while (d->state != Connected && d->socket->waitForReadyRead(deadline.remainingTime())) { - // Loop while the protocol handshake is taking place. - } + waitForProtocolHandshake(deadline); // Report any error that may occur. if (d->state != Connected) { @@ -399,6 +390,18 @@ bool QHttpSocketEngine::waitForReadOrWrite(bool *readyToRead, bool *readyToWrite return canWrite; } +void QHttpSocketEngine::waitForProtocolHandshake(QDeadlineTimer deadline) const +{ + Q_D(const QHttpSocketEngine); + + // If we're not connected yet, wait until we are (and until bytes have + // been received, i.e. the socket has connected, we have sent the + // greeting, and then received the response), or until an error occurs. + while (d->state != Connected && d->socket->waitForReadyRead(deadline.remainingTime())) { + // Loop while the protocol handshake is taking place. + } +} + bool QHttpSocketEngine::isReadNotificationEnabled() const { Q_D(const QHttpSocketEngine); diff --git a/src/network/socket/qhttpsocketengine_p.h b/src/network/socket/qhttpsocketengine_p.h index 70ffd06b6ba..7926abf5138 100644 --- a/src/network/socket/qhttpsocketengine_p.h +++ b/src/network/socket/qhttpsocketengine_p.h @@ -101,6 +101,8 @@ public: QDeadlineTimer deadline = QDeadlineTimer{DefaultTimeout}, bool *timedOut = nullptr) override; + void waitForProtocolHandshake(QDeadlineTimer deadline) const; + bool isReadNotificationEnabled() const override; void setReadNotificationEnabled(bool enable) override; bool isWriteNotificationEnabled() const override; |