diff options
author | Liang Qi <liang.qi@qt.io> | 2017-10-11 20:17:45 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-10-11 20:17:45 +0200 |
commit | 825df0cef516fb84adab88a31106e214f2b29b2d (patch) | |
tree | e6e7fb12b1c77faa65df20106c8bf342a410b690 /src | |
parent | 75042d31d1d267d0a4091932c95579747a102e9d (diff) | |
parent | cd26439ac7ca1a444e9b5534a504afb0bb411890 (diff) | |
download | qtwebsockets-825df0cef516fb84adab88a31106e214f2b29b2d.tar.gz |
Merge remote-tracking branch 'origin/5.10' into dev
Conflicts:
examples/websockets/simplechat/chatserver.cpp
Change-Id: I98697cef4c05516b5b4122ad81c084546d57115f
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/qmlwebsockets/qqmlwebsocket.h | 2 | ||||
-rw-r--r-- | src/websockets/qwebsocket_p.cpp | 7 | ||||
-rw-r--r-- | src/websockets/qwebsockethandshakerequest.cpp | 18 | ||||
-rw-r--r-- | src/websockets/qwebsocketserver.h | 3 |
4 files changed, 15 insertions, 15 deletions
diff --git a/src/imports/qmlwebsockets/qqmlwebsocket.h b/src/imports/qmlwebsockets/qqmlwebsocket.h index c3a808f..8db435d 100644 --- a/src/imports/qmlwebsockets/qqmlwebsocket.h +++ b/src/imports/qmlwebsockets/qqmlwebsocket.h @@ -54,7 +54,6 @@ class QQmlWebSocket : public QObject, public QQmlParserStatus Q_DISABLE_COPY(QQmlWebSocket) Q_INTERFACES(QQmlParserStatus) - Q_ENUMS(Status) Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged) @@ -73,6 +72,7 @@ public: Closed = 3, Error = 4 }; + Q_ENUM(Status) QUrl url() const; void setUrl(const QUrl &url); diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index 5253804..5e1a103 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -633,7 +633,7 @@ void QWebSocketPrivate::makeConnections(const QTcpSocket *pTcpSocket) void QWebSocketPrivate::releaseConnections(const QTcpSocket *pTcpSocket) { if (Q_LIKELY(pTcpSocket)) - pTcpSocket->disconnect(pTcpSocket); + pTcpSocket->disconnect(); m_dataProcessor.disconnect(); } @@ -1011,7 +1011,7 @@ void QWebSocketPrivate::processHandshake(QTcpSocket *pSocket) if (!ok) errorDescription = QWebSocket::tr("Accept-Key received from server %1 does not match the client key %2.") - .arg(acceptKey).arg(accept); + .arg(acceptKey, accept); } else { errorDescription = QWebSocket::tr("QWebSocketPrivate::processHandshake: Invalid statusline in response: %1.") @@ -1145,7 +1145,8 @@ void QWebSocketPrivate::socketDestroyed(QObject *socket) */ void QWebSocketPrivate::processData() { - Q_ASSERT(m_pSocket); + if (!m_pSocket) // disconnected with data still in-bound + return; while (m_pSocket->bytesAvailable()) { if (state() == QAbstractSocket::ConnectingState) { if (!m_pSocket->canReadLine()) diff --git a/src/websockets/qwebsockethandshakerequest.cpp b/src/websockets/qwebsockethandshakerequest.cpp index ddeee2d..e6a626c 100644 --- a/src/websockets/qwebsockethandshakerequest.cpp +++ b/src/websockets/qwebsockethandshakerequest.cpp @@ -318,17 +318,17 @@ void QWebSocketHandshakeRequest::readHandshake(QTextStream &textStream, int maxH //optional headers m_origin = m_headers.value(QStringLiteral("origin"), QString()); const QStringList protocolLines = m_headers.values(QStringLiteral("sec-websocket-protocol")); - for (QStringList::const_iterator pl = protocolLines.begin(); pl != protocolLines.end(); ++pl) { - QStringList protocols = (*pl).split(QStringLiteral(","), QString::SkipEmptyParts); - for (QStringList::const_iterator p = protocols.begin(); p != protocols.end(); ++p) - m_protocols << (*p).trimmed(); + for (const QString& pl : protocolLines) { + const QStringList protocols = pl.split(QStringLiteral(","), QString::SkipEmptyParts); + for (const QString& p : protocols) + m_protocols << p.trimmed(); } + const QStringList extensionLines = m_headers.values(QStringLiteral("sec-websocket-extensions")); - for (QStringList::const_iterator el = extensionLines.begin(); - el != extensionLines.end(); ++el) { - QStringList extensions = (*el).split(QStringLiteral(","), QString::SkipEmptyParts); - for (QStringList::const_iterator e = extensions.begin(); e != extensions.end(); ++e) - m_extensions << (*e).trimmed(); + for (const QString& el : extensionLines) { + const QStringList extensions = el.split(QStringLiteral(","), QString::SkipEmptyParts); + for (const QString& e : extensions) + m_extensions << e.trimmed(); } //TODO: authentication field diff --git a/src/websockets/qwebsocketserver.h b/src/websockets/qwebsocketserver.h index 8a78c57..decd7c3 100644 --- a/src/websockets/qwebsocketserver.h +++ b/src/websockets/qwebsocketserver.h @@ -65,8 +65,6 @@ class Q_WEBSOCKETS_EXPORT QWebSocketServer : public QObject Q_DISABLE_COPY(QWebSocketServer) Q_DECLARE_PRIVATE(QWebSocketServer) - Q_ENUMS(SslMode) - public: enum SslMode { #ifndef QT_NO_SSL @@ -74,6 +72,7 @@ public: #endif NonSecureMode = 1 }; + Q_ENUM(SslMode) explicit QWebSocketServer(const QString &serverName, SslMode secureMode, QObject *parent = nullptr); |