diff options
author | Markus Goetz <Markus.Goetz@nokia.com> | 2009-08-18 06:33:09 (GMT) |
---|---|---|
committer | Markus Goetz <Markus.Goetz@nokia.com> | 2009-08-18 06:34:12 (GMT) |
commit | f30e54f2e8f89ca2c92032457a98b3f98010ba44 (patch) | |
tree | 30da13df4d7bebd6d5f114cf477eb74e5507367e /tests | |
parent | 95cb2bb6cbdf2dcc0a035105104a4c08ecc43e83 (diff) | |
download | Qt-f30e54f2e8f89ca2c92032457a98b3f98010ba44.zip Qt-f30e54f2e8f89ca2c92032457a98b3f98010ba44.tar.gz Qt-f30e54f2e8f89ca2c92032457a98b3f98010ba44.tar.bz2 |
QSslSocket: Clear readBuffer and writeBuffer on close()
Fixes https://bugs.webkit.org/show_bug.cgi?id=28016
Reviewed-by: andreas
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qsslsocket/tst_qsslsocket.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 4f466a1..f3bc4c4 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -172,6 +172,7 @@ private slots: void disconnectFromHostWhenConnecting(); void disconnectFromHostWhenConnected(); void resetProxy(); + void readFromClosedSocket(); static void exitLoop() { @@ -1508,6 +1509,34 @@ void tst_QSslSocket::resetProxy() QVERIFY2(socket2.waitForConnected(10000), qPrintable(socket.errorString())); } +// make sure a closed socket has no bytesAvailable() +// related to https://bugs.webkit.org/show_bug.cgi?id=28016 +void tst_QSslSocket::readFromClosedSocket() +{ + QSslSocketPtr socket = newSocket(); + socket->ignoreSslErrors(); + socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->ignoreSslErrors(); + socket->waitForConnected(); + socket->waitForEncrypted(); + // provoke a response by sending a request + socket->write("GET /gif/fluke.gif HTTP/1.1\n"); + socket->write("Host: "); + socket->write(QtNetworkSettings::serverName().toLocal8Bit().constData()); + socket->write("\n"); + socket->write("\n"); + socket->waitForBytesWritten(); + socket->waitForReadyRead(); + QVERIFY(socket->state() == QAbstractSocket::ConnectedState); + QVERIFY(socket->bytesAvailable()); + socket->close(); + QVERIFY(!socket->bytesAvailable()); + QVERIFY(!socket->bytesToWrite()); + socket->waitForDisconnected(); + QVERIFY(!socket->bytesAvailable()); + QVERIFY(!socket->bytesToWrite()); +} + #endif // QT_NO_OPENSSL QTEST_MAIN(tst_QSslSocket) |