QHttpSocketEngine: de-duplicate some code
Change-Id: I4699e3ea0d4687a9772f6f90e6033f5582c1a346 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
738a5ad4f2
commit
6ecf43120f
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user