diff options
-rw-r--r-- | .qmake.conf | 2 | ||||
-rw-r--r-- | src/websockets/qwebsocket.cpp | 3 | ||||
-rw-r--r-- | src/websockets/qwebsocket_p.cpp | 17 | ||||
-rw-r--r-- | src/websockets/qwebsocketdataprocessor.cpp | 11 | ||||
-rw-r--r-- | src/websockets/qwebsocketprotocol.cpp | 2 |
5 files changed, 26 insertions, 9 deletions
diff --git a/.qmake.conf b/.qmake.conf index bbf484f..0134c4c 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -3,4 +3,4 @@ load(qt_build_config) CONFIG += warning_clean DEFINES += QT_NO_FOREACH -MODULE_VERSION = 5.15.3 +MODULE_VERSION = 5.15.13 diff --git a/src/websockets/qwebsocket.cpp b/src/websockets/qwebsocket.cpp index 144268f..526c561 100644 --- a/src/websockets/qwebsocket.cpp +++ b/src/websockets/qwebsocket.cpp @@ -447,6 +447,9 @@ void QWebSocket::open(const QNetworkRequest &request) The size of the \a payload cannot be bigger than 125. If it is larger, the \a payload is clipped to 125 bytes. + \note QWebSocket and QWebSocketServer handles ping requests internally, + which means they automatically send back a pong response to the peer. + \sa pong() */ void QWebSocket::ping(const QByteArray &payload) diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index aedc3c6..cf3087f 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -270,6 +270,11 @@ QSslConfiguration QWebSocketPrivate::sslConfiguration() const void QWebSocketPrivate::ignoreSslErrors(const QList<QSslError> &errors) { m_configuration.m_ignoredSslErrors = errors; + if (Q_LIKELY(m_pSocket)) { + QSslSocket *pSslSocket = qobject_cast<QSslSocket *>(m_pSocket); + if (Q_LIKELY(pSslSocket)) + pSslSocket->ignoreSslErrors(errors); + } } /*! @@ -424,8 +429,10 @@ void QWebSocketPrivate::open(const QNetworkRequest &request, bool mask) QSslSocket *sslSocket = new QSslSocket(q); m_pSocket = sslSocket; if (Q_LIKELY(m_pSocket)) { - m_pSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1); - m_pSocket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); + QObject::connect(sslSocket, &QSslSocket::connected, [sslSocket](){ + sslSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1); + sslSocket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); + }); m_pSocket->setReadBufferSize(m_readBufferSize); m_pSocket->setPauseMode(m_pauseMode); @@ -453,8 +460,10 @@ void QWebSocketPrivate::open(const QNetworkRequest &request, bool mask) if (url.scheme() == QStringLiteral("ws")) { m_pSocket = new QTcpSocket(q); if (Q_LIKELY(m_pSocket)) { - m_pSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1); - m_pSocket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); + QObject::connect(m_pSocket, &QTcpSocket::connected, [this](){ + m_pSocket->setSocketOption(QAbstractSocket::LowDelayOption, 1); + m_pSocket->setSocketOption(QAbstractSocket::KeepAliveOption, 1); + }); m_pSocket->setReadBufferSize(m_readBufferSize); m_pSocket->setPauseMode(m_pauseMode); diff --git a/src/websockets/qwebsocketdataprocessor.cpp b/src/websockets/qwebsocketdataprocessor.cpp index 0d2e927..2affdd5 100644 --- a/src/websockets/qwebsocketdataprocessor.cpp +++ b/src/websockets/qwebsocketdataprocessor.cpp @@ -202,6 +202,7 @@ bool QWebSocketDataProcessor::process(QIODevice *pIoDevice) return true; } + bool isFinalFrame = frame.isFinalFrame(); if (m_opCode == QWebSocketProtocol::OpCodeText) { QString frameTxt = m_pTextCodec->toUnicode(frame.payload().constData(), frame.payload().size(), @@ -215,14 +216,17 @@ bool QWebSocketDataProcessor::process(QIODevice *pIoDevice) return true; } else { m_textMessage.append(frameTxt); - Q_EMIT textFrameReceived(frameTxt, frame.isFinalFrame()); + frame.clear(); + Q_EMIT textFrameReceived(frameTxt, isFinalFrame); } } else { m_binaryMessage.append(frame.payload()); - Q_EMIT binaryFrameReceived(frame.payload(), frame.isFinalFrame()); + QByteArray payload = frame.payload(); + frame.clear(); + Q_EMIT binaryFrameReceived(payload, isFinalFrame); } - if (frame.isFinalFrame()) { + if (isFinalFrame) { isDone = true; if (m_opCode == QWebSocketProtocol::OpCodeText) { const QString textMessage(m_textMessage); @@ -259,6 +263,7 @@ void QWebSocketDataProcessor::clear() m_binaryMessage.clear(); m_textMessage.clear(); m_payloadLength = 0; + frame.clear(); if (m_pConverterState) { if ((m_pConverterState->remainingChars != 0) || (m_pConverterState->invalidChars != 0)) { delete m_pConverterState; diff --git a/src/websockets/qwebsocketprotocol.cpp b/src/websockets/qwebsocketprotocol.cpp index df87a93..d0465f1 100644 --- a/src/websockets/qwebsocketprotocol.cpp +++ b/src/websockets/qwebsocketprotocol.cpp @@ -210,7 +210,7 @@ void QWebSocketProtocol::mask(char *payload, quint64 size, quint32 maskingKey) quint8((maskingKey & 0x0000FF00u) >> 8), quint8((maskingKey & 0x000000FFu)) }; - int i = 0; + quint64 i = 0; while (size-- > 0) *payload++ ^= mask[i++ % 4]; } |