Skip to content

Commit

Permalink
QSslSocket: implement skip() overload
Browse files Browse the repository at this point in the history
As QAbstractSocket does not handle most cases for this socket type, we
should override skip() in QSslSocketPrivate implementation.

In unencrypted mode, QSslSocket should forward skipping to the plain
socket. If a connection is secure, we just need to check the connection
state.

Change-Id: I56602c6427b8617e8a9f453809a30fb2914ad798
Reviewed-by: Edward Welbourne <[email protected]>
Reviewed-by: Mårten Nordheim <[email protected]>
Reviewed-by: Timur Pocheptsov <[email protected]>
  • Loading branch information
Alex Trotsenko committed Oct 7, 2017
1 parent 06089a1 commit ca49f13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/network/ssl/qsslsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2644,6 +2644,20 @@ QByteArray QSslSocketPrivate::peek(qint64 maxSize)
}
}

/*!
\internal
*/
qint64 QSslSocketPrivate::skip(qint64 maxSize)
{
if (mode == QSslSocket::UnencryptedMode && !autoStartHandshake)
return plainSocket->skip(maxSize);

// In encrypted mode, the SSL backend writes decrypted data directly into the
// QIODevice's read buffer. As this buffer is always emptied by the caller,
// we need to wait for more incoming data.
return (state == QAbstractSocket::ConnectedState) ? Q_INT64_C(0) : Q_INT64_C(-1);
}

/*!
\internal
*/
Expand Down
1 change: 1 addition & 0 deletions src/network/ssl/qsslsocket_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class QSslSocketPrivate : public QTcpSocketPrivate

virtual qint64 peek(char *data, qint64 maxSize) override;
virtual QByteArray peek(qint64 maxSize) override;
qint64 skip(qint64 maxSize) override;
bool flush() override;

// Platform specific functions
Expand Down

0 comments on commit ca49f13

Please sign in to comment.