diff options
author | Liang Qi <liang.qi@qt.io> | 2016-09-21 09:30:52 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-09-21 09:30:52 +0200 |
commit | a0855a4351cc8e66035cb3f88a7dd4f085456e2d (patch) | |
tree | 4c314fabc7efe0890b346ad6d2c42308e6b46913 | |
parent | 488aa3408604391ddcb1497a3193bc9a52af7e1f (diff) | |
parent | ccb138548314a767a897496c74c04a261a391027 (diff) | |
download | qtwebsockets-a0855a4351cc8e66035cb3f88a7dd4f085456e2d.tar.gz |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
src/websockets/qwebsocket_p.cpp
Change-Id: Ib6b9655985246c9ce3968f1eb662be457465a937
-rw-r--r-- | .qmake.conf | 1 | ||||
-rw-r--r-- | examples/websockets/simplechat/chatserver.cpp | 3 | ||||
-rw-r--r-- | examples/websockets/websockets.pro | 1 | ||||
-rw-r--r-- | src/imports/qmlwebsockets/qmlwebsockets_plugin.h | 2 | ||||
-rw-r--r-- | src/websockets/qwebsocket_p.cpp | 16 | ||||
-rw-r--r-- | src/websockets/qwebsocket_p.h | 2 | ||||
-rw-r--r-- | tests/manual/websockets/tst_websockets.cpp | 5 |
7 files changed, 13 insertions, 17 deletions
diff --git a/.qmake.conf b/.qmake.conf index be2bd3b..d94a2e0 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,5 +1,6 @@ load(qt_build_config) CONFIG += warning_clean +DEFINES += QT_NO_FOREACH MODULE_VERSION = 5.9.0 diff --git a/examples/websockets/simplechat/chatserver.cpp b/examples/websockets/simplechat/chatserver.cpp index 5a0c998..ae207f5 100644 --- a/examples/websockets/simplechat/chatserver.cpp +++ b/examples/websockets/simplechat/chatserver.cpp @@ -93,8 +93,7 @@ void ChatServer::onNewConnection() void ChatServer::processMessage(QString message) { QWebSocket *pSender = qobject_cast<QWebSocket *>(sender()); - Q_FOREACH (QWebSocket *pClient, m_clients) - { + for (QWebSocket *pClient : qAsConst(m_clients)) { if (pClient != pSender) //don't echo message back to sender { pClient->sendTextMessage(message); diff --git a/examples/websockets/websockets.pro b/examples/websockets/websockets.pro index 8ad9645..fa6c0c0 100644 --- a/examples/websockets/websockets.pro +++ b/examples/websockets/websockets.pro @@ -1,4 +1,5 @@ TEMPLATE = subdirs +QT_FOR_CONFIG += network SUBDIRS = echoclient \ echoserver \ diff --git a/src/imports/qmlwebsockets/qmlwebsockets_plugin.h b/src/imports/qmlwebsockets/qmlwebsockets_plugin.h index 318e0c7..749d830 100644 --- a/src/imports/qmlwebsockets/qmlwebsockets_plugin.h +++ b/src/imports/qmlwebsockets/qmlwebsockets_plugin.h @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE class QtWebSocketsDeclarativeModule : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QtWebSocketsDeclarativeModule(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index 436c819..1a47e76 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -305,11 +305,9 @@ QWebSocket *QWebSocketPrivate::upgradeFrom(QTcpSocket *pTcpSocket, QWebSocket *pWebSocket = new QWebSocket(pTcpSocket, response.acceptedVersion(), parent); if (Q_LIKELY(pWebSocket)) { QNetworkRequest netRequest(request.requestUrl()); - QMapIterator<QString, QString> headerIter(request.headers()); - while (headerIter.hasNext()) { - headerIter.next(); - netRequest.setRawHeader(headerIter.key().toLatin1(), headerIter.value().toLatin1()); - } + const auto headers = request.headers(); + for (auto it = headers.begin(), end = headers.end(); it != end; ++it) + netRequest.setRawHeader(it.key().toLatin1(), it.value().toLatin1()); #ifndef QT_NO_SSL if (QSslSocket *sslSock = qobject_cast<QSslSocket *>(pTcpSocket)) pWebSocket->setSslConfiguration(sslSock->sslConfiguration()); @@ -1204,7 +1202,7 @@ QString QWebSocketPrivate::createHandShakeRequest(QString resourceName, QString extensions, QString protocols, QByteArray key, - QList<QPair<QString, QString> > headers) + const QList<QPair<QString, QString> > &headers) { QStringList handshakeRequest; if (resourceName.contains(QStringLiteral("\r\n"))) { @@ -1247,11 +1245,9 @@ QString QWebSocketPrivate::createHandShakeRequest(QString resourceName, if (protocols.length() > 0) handshakeRequest << QStringLiteral("Sec-WebSocket-Protocol: ") % protocols; - QListIterator<QPair<QString, QString> > headerIter(headers); - while (headerIter.hasNext()) { - const QPair<QString,QString> &header = headerIter.next(); + for (const auto &header : headers) handshakeRequest << header.first % QStringLiteral(": ") % header.second; - } + handshakeRequest << QStringLiteral("\r\n"); return handshakeRequest.join(QStringLiteral("\r\n")); diff --git a/src/websockets/qwebsocket_p.h b/src/websockets/qwebsocket_p.h index 139c7ff..4863de7 100644 --- a/src/websockets/qwebsocket_p.h +++ b/src/websockets/qwebsocket_p.h @@ -193,7 +193,7 @@ private: QString extensions, QString protocols, QByteArray key, - QList<QPair<QString, QString> > headers); + const QList<QPair<QString, QString> > &headers); static QWebSocket *upgradeFrom(QTcpSocket *tcpSocket, const QWebSocketHandshakeRequest &request, diff --git a/tests/manual/websockets/tst_websockets.cpp b/tests/manual/websockets/tst_websockets.cpp index 8568532..6b327aa 100644 --- a/tests/manual/websockets/tst_websockets.cpp +++ b/tests/manual/websockets/tst_websockets.cpp @@ -152,12 +152,11 @@ void tst_WebSocketsTest::testLocalAddress() void tst_WebSocketsTest::testPeerAddress() { QHostInfo hostInfo = QHostInfo::fromName(m_url.host()); - QList<QHostAddress> addresses = hostInfo.addresses(); + const QList<QHostAddress> addresses = hostInfo.addresses(); QVERIFY(addresses.length() > 0); QHostAddress peer = m_pWebSocket->peerAddress(); bool found = false; - Q_FOREACH (const QHostAddress &a, addresses) - { + for (const QHostAddress &a : addresses) { if (a == peer) { found = true; |