Details
Description
If QSslSocket::setReadBufferSize() is called before the connexion is established, the socket does not read data after the first readAll(). A call to encryptedBytesAvailable() return a non null value, and the byte cannot be read.
Here is an example to reproduce the problem:
#include <QCoreApplication> #include <QSslSocket> #include <QTimer> #include <QtDebug> #include <QObject> class Transmitter : public QObject { Q_OBJECT public: Transmitter(QObject *parent=0); QTimer testTimer; QSslSocket *socket; public slots: void handleEncrypted(); void handleData(); }; Transmitter::Transmitter(QObject *parent) : QObject(parent) { connect(&testTimer, SIGNAL(timeout()), this, SLOT(handleData())); socket = new QSslSocket(this); socket->setReadBufferSize(1000); // limit to 1 kb/sec connect(socket, SIGNAL(encrypted()), this, SLOT(handleEncrypted())); } void Transmitter::handleEncrypted() { qDebug() << "Connected."; socket->write("GET /mail/help/images/googlemail.gif HTTP/1.0\r\n\r\n"); testTimer.start(1000); } void Transmitter::handleData() { QByteArray data = socket->readAll(); //socket->flush(); work with flush qDebug() << "BytesAvailable:" << socket->bytesAvailable() << "| EncryptedBytesAvailable:" << socket->encryptedBytesAvailable() << "size = " << data.size(); } int main(int argc, char *argv[]) { QCoreApplication qapp(argc, argv); qDebug() << "Connecting..."; Transmitter *trans = new Transmitter; trans->socket->connectToHostEncrypted("mail.google.com", 443); return qapp.exec(); } #include "main.moc"