summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qsslsocket/tst_qsslsocket.cpp29
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)