diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 84b8f3a8d9..9d11506fcb 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -2286,6 +2286,9 @@ void QSslSocketPrivate::createPlainSocket(QIODevice::OpenMode openMode) q->connect(plainSocket, SIGNAL(channelBytesWritten(int, qint64)), q, SLOT(_q_channelBytesWrittenSlot(int, qint64)), Qt::DirectConnection); + q->connect(plainSocket, SIGNAL(readChannelFinished()), + q, SLOT(_q_readChannelFinishedSlot()), + Qt::DirectConnection); #ifndef QT_NO_NETWORKPROXY q->connect(plainSocket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), q, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); @@ -2504,6 +2507,15 @@ void QSslSocketPrivate::_q_channelBytesWrittenSlot(int channel, qint64 written) emit q->channelBytesWritten(channel, written); } +/*! + \internal +*/ +void QSslSocketPrivate::_q_readChannelFinishedSlot() +{ + Q_Q(QSslSocket); + emit q->readChannelFinished(); +} + /*! \internal */ diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h index 1b29cd4637..39e70bccda 100644 --- a/src/network/ssl/qsslsocket.h +++ b/src/network/ssl/qsslsocket.h @@ -224,6 +224,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_channelReadyReadSlot(int)) Q_PRIVATE_SLOT(d_func(), void _q_bytesWrittenSlot(qint64)) Q_PRIVATE_SLOT(d_func(), void _q_channelBytesWrittenSlot(int, qint64)) + Q_PRIVATE_SLOT(d_func(), void _q_readChannelFinishedSlot()) Q_PRIVATE_SLOT(d_func(), void _q_flushWriteBuffer()) Q_PRIVATE_SLOT(d_func(), void _q_flushReadBuffer()) Q_PRIVATE_SLOT(d_func(), void _q_resumeImplementation()) diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h index aec3437422..827f27cff1 100644 --- a/src/network/ssl/qsslsocket_p.h +++ b/src/network/ssl/qsslsocket_p.h @@ -180,6 +180,7 @@ public: void _q_channelReadyReadSlot(int); void _q_bytesWrittenSlot(qint64); void _q_channelBytesWrittenSlot(int, qint64); + void _q_readChannelFinishedSlot(); void _q_flushWriteBuffer(); void _q_flushReadBuffer(); void _q_resumeImplementation(); diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 8a8522760c..1545743ee9 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -237,6 +237,7 @@ private slots: void ephemeralServerKey(); void allowedProtocolNegotiation(); void pskServer(); + void forwardReadChannelFinished(); #endif void setEmptyDefaultConfiguration(); // this test should be last @@ -3771,6 +3772,28 @@ void tst_QSslSocket::pskServer() QCOMPARE(disconnectedSpy.count(), 1); } +void tst_QSslSocket::forwardReadChannelFinished() +{ + if (!QSslSocket::supportsSsl()) + QSKIP("Needs SSL"); + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + QSKIP("This test doesn't work via a proxy"); + + QSslSocket socket; + QSignalSpy readChannelFinishedSpy(&socket, &QAbstractSocket::readChannelFinished); + connect(&socket, &QSslSocket::encrypted, [&socket]() { + const auto data = QString("GET /ip HTTP/1.0\r\nHost: %1\r\n\r\nAccept: */*\r\n\r\n") + .arg(QtNetworkSettings::serverLocalName()).toUtf8(); + socket.write(data); + }); + connect(&socket, &QSslSocket::readChannelFinished, + &QTestEventLoop::instance(), &QTestEventLoop::exitLoop); + socket.connectToHostEncrypted(QtNetworkSettings::serverLocalName(), 443); + enterLoop(10); + QVERIFY(readChannelFinishedSpy.count()); +} + #endif // QT_NO_OPENSSL #endif // QT_NO_SSL