diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/websockets/qwebsocket_p.cpp | 25 | ||||
-rw-r--r-- | src/websockets/qwebsockethandshakeresponse.cpp | 8 |
2 files changed, 21 insertions, 12 deletions
diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index b9d37a1..f483e12 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -384,12 +384,6 @@ void QWebSocketPrivate::open(const QUrl &url, bool mask) m_pSocket->setPauseMode(m_pauseMode); makeConnections(m_pSocket.data()); - QObject::connect(sslSocket, &QSslSocket::encryptedBytesWritten, q, - &QWebSocket::bytesWritten); - typedef void (QSslSocket:: *sslErrorSignalType)(const QList<QSslError> &); - QObject::connect(sslSocket, - static_cast<sslErrorSignalType>(&QSslSocket::sslErrors), - q, &QWebSocket::sslErrors); setSocketState(QAbstractSocket::ConnectingState); sslSocket->setSslConfiguration(m_configuration.m_sslConfiguration); @@ -418,8 +412,6 @@ void QWebSocketPrivate::open(const QUrl &url, bool mask) m_pSocket->setPauseMode(m_pauseMode); makeConnections(m_pSocket.data()); - QObject::connect(m_pSocket.data(), &QAbstractSocket::bytesWritten, q, - &QWebSocket::bytesWritten); setSocketState(QAbstractSocket::ConnectingState); #ifndef QT_NO_NETWORKPROXY m_pSocket->setProxy(m_configuration.m_proxy); @@ -537,7 +529,7 @@ void QWebSocketPrivate::makeConnections(const QTcpSocket *pTcpSocket) #ifndef QT_NO_NETWORKPROXY QObject::connect(pTcpSocket, &QAbstractSocket::proxyAuthenticationRequired, q, &QWebSocket::proxyAuthenticationRequired); -#endif +#endif // QT_NO_NETWORKPROXY QObject::connect(pTcpSocket, &QAbstractSocket::readChannelFinished, q, &QWebSocket::readChannelFinished); QObject::connect(pTcpSocket, &QAbstractSocket::aboutToClose, q, &QWebSocket::aboutToClose); @@ -550,6 +542,21 @@ void QWebSocketPrivate::makeConnections(const QTcpSocket *pTcpSocket) //with QTcpSocket there is no problem, but with QSslSocket the processing hangs QObjectPrivate::connect(pTcpSocket, &QAbstractSocket::readyRead, this, &QWebSocketPrivate::processData, Qt::QueuedConnection); +#ifndef QT_NO_SSL + const QSslSocket * const sslSocket = qobject_cast<const QSslSocket *>(pTcpSocket); + if (sslSocket) { + QObject::connect(sslSocket, &QSslSocket::encryptedBytesWritten, q, + &QWebSocket::bytesWritten); + typedef void (QSslSocket:: *sslErrorSignalType)(const QList<QSslError> &); + QObject::connect(sslSocket, + static_cast<sslErrorSignalType>(&QSslSocket::sslErrors), + q, &QWebSocket::sslErrors); + } else +#endif // QT_NO_SSL + { + QObject::connect(pTcpSocket, &QAbstractSocket::bytesWritten, q, + &QWebSocket::bytesWritten); + } } QObject::connect(&m_dataProcessor, &QWebSocketDataProcessor::textFrameReceived, q, diff --git a/src/websockets/qwebsockethandshakeresponse.cpp b/src/websockets/qwebsockethandshakeresponse.cpp index d8fa5cf..a3963cd 100644 --- a/src/websockets/qwebsockethandshakeresponse.cpp +++ b/src/websockets/qwebsockethandshakeresponse.cpp @@ -41,6 +41,7 @@ #include <QtCore/QByteArray> #include <QtCore/QStringList> #include <QtCore/QDateTime> +#include <QtCore/QLocale> #include <QtCore/QCryptographicHash> #include <QtCore/QSet> #include <QtCore/QList> @@ -178,14 +179,15 @@ QString QWebSocketHandshakeResponse::getHandshakeResponse( } else { if (origin.isEmpty()) origin = QStringLiteral("*"); + QDateTime datetime = QDateTime::currentDateTimeUtc(); response << QStringLiteral("Server: ") % serverName << QStringLiteral("Access-Control-Allow-Credentials: false") << QStringLiteral("Access-Control-Allow-Methods: GET") << QStringLiteral("Access-Control-Allow-Headers: content-type") << QStringLiteral("Access-Control-Allow-Origin: ") % origin << - QStringLiteral("Date: ") % - QDateTime::currentDateTimeUtc() - .toString(QStringLiteral("ddd, dd MMM yyyy hh:mm:ss 'GMT'")); + QStringLiteral("Date: ") % QLocale::c() + .toString(datetime, QStringLiteral("ddd, dd MMM yyyy hh:mm:ss 'GMT'")); + m_acceptedVersion = QWebSocketProtocol::currentVersion(); m_canUpgrade = true; |