diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-03-17 16:42:06 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-03-17 16:42:06 +0100 |
commit | 01eaae540cace513fa73340631dbb3a854c713b5 (patch) | |
tree | d2099ddf92820d52877f88fd52e4c5e1a4b29ab9 /src | |
parent | 009ffb330e43b57ed7539ae07c065524a6d4dc65 (diff) | |
parent | 2348cac4fa6baab447a21286ac8680ad6829008f (diff) | |
download | qtwebsockets-01eaae540cace513fa73340631dbb3a854c713b5.tar.gz |
Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: I75fb372eec95215dab2f4807a842c2435ac7344e
Diffstat (limited to 'src')
-rw-r--r-- | src/websockets/doc/qtwebsockets.qdocconf | 6 | ||||
-rw-r--r-- | src/websockets/doc/src/index.qdoc | 13 | ||||
-rw-r--r-- | src/websockets/doc/src/qtwebsockets-module.qdoc | 5 | ||||
-rw-r--r-- | src/websockets/qwebsocket_p.cpp | 7 | ||||
-rw-r--r-- | src/websockets/qwebsocketframe.cpp | 4 | ||||
-rw-r--r-- | src/websockets/qwebsockethandshakerequest.cpp | 18 |
6 files changed, 40 insertions, 13 deletions
diff --git a/src/websockets/doc/qtwebsockets.qdocconf b/src/websockets/doc/qtwebsockets.qdocconf index 3f87cef..2e1e15b 100644 --- a/src/websockets/doc/qtwebsockets.qdocconf +++ b/src/websockets/doc/qtwebsockets.qdocconf @@ -37,7 +37,7 @@ qhp.QtWebSockets.subprojects.examples.sortPages = true tagfile = ../../../doc/qtwebsockets/qtwebsockets.tags -depends += qtcore qtnetwork qtdoc +depends += qtcore qtnetwork qtdoc qmake headerdirs += .. \ ../../imports @@ -50,6 +50,10 @@ sourcedirs += .. \ exampledirs += ../../../examples/websockets \ snippets +examples.fileextensions += "*.html" + +imagedirs += ../../../examples/websockets/doc/images + manifestmeta.thumbnail.names += "QtWebSockets/*" navigation.landingpage = "Qt WebSockets" diff --git a/src/websockets/doc/src/index.qdoc b/src/websockets/doc/src/index.qdoc index a277e69..0d28036 100644 --- a/src/websockets/doc/src/index.qdoc +++ b/src/websockets/doc/src/index.qdoc @@ -31,10 +31,17 @@ \title Qt WebSockets \brief Provides an implementation of the WebSocket protocol. - The QtWebSockets module implements the WebSocket protocol as specified in - \l {http://tools.ietf.org/html/rfc6455} {RFC 6455}. - It solely depends on Qt (no external dependencies). + WebSocket is a web-based protocol designed to enable two-way communication + between a client application and a remote host. It enables the two entities + to send data back and forth if the initial handshake succeeds. WebSocket is + the solution for applications that struggle to get real-time data feeds + with less network latency and minimum data exchange. + The Qt WebSockets module implements the WebSocket protocol as specified in + \l {http://tools.ietf.org/html/rfc6455} {RFC 6455}. It provides C++ and QML + interfaces that enable Qt applications to act as a server that can process + WebSocket-based requests, or a client that can consume data received from + the server, or both. To use this module in your application, use the following include statement: diff --git a/src/websockets/doc/src/qtwebsockets-module.qdoc b/src/websockets/doc/src/qtwebsockets-module.qdoc index 0383475..acbe2ac 100644 --- a/src/websockets/doc/src/qtwebsockets-module.qdoc +++ b/src/websockets/doc/src/qtwebsockets-module.qdoc @@ -30,7 +30,7 @@ \ingroup modules \qtvariable websockets \since 5.3 - \brief List of C++ classes that provide WebSockets communication. + \brief List of C++ classes that enable WebSocket-based communication. To use these classes in your application, use the following include statement: @@ -51,9 +51,8 @@ \qmlmodule QtWebSockets 1.0 \title Qt WebSockets QML Types \ingroup qmlmodules - \brief Provides QML types for WebSockets communication. + \brief Provides QML types for WebSocket-based communication. - \annotatedlist websockets-qml The QML types are accessed by using: \code diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp index f6b2f43..2bb5151 100644 --- a/src/websockets/qwebsocket_p.cpp +++ b/src/websockets/qwebsocket_p.cpp @@ -441,8 +441,13 @@ void QWebSocketPrivate::ping(const QByteArray &payload) { QByteArray payloadTruncated = payload.left(125); m_pingTimer.restart(); + quint32 maskingKey = 0; + if (m_mustMask) + maskingKey = generateMaskingKey(); QByteArray pingFrame = getFrameHeader(QWebSocketProtocol::OpCodePing, payloadTruncated.size(), - 0 /*do not mask*/, true); + maskingKey, true); + if (m_mustMask) + QWebSocketProtocol::mask(&payloadTruncated, maskingKey); pingFrame.append(payloadTruncated); qint64 ret = writeFrame(pingFrame); Q_UNUSED(ret); diff --git a/src/websockets/qwebsocketframe.cpp b/src/websockets/qwebsocketframe.cpp index e604a5e..a4e644b 100644 --- a/src/websockets/qwebsocketframe.cpp +++ b/src/websockets/qwebsocketframe.cpp @@ -307,7 +307,7 @@ bool QWebSocketFrame::isValid() const // The arm compiler of Visual Studio 2013 Update 3 crashes when // trying to optimize QWebSocketFrame::readFrame. Hence turn // those off for this snippet -#if defined(Q_OS_WINPHONE) && defined(__ARM__) +#if (defined(Q_OS_WINPHONE) || defined(Q_OS_WINRT)) && defined(__ARM__) # pragma optimize("", off) #endif @@ -519,7 +519,7 @@ QWebSocketFrame QWebSocketFrame::readFrame(QIODevice *pIoDevice) return frame; } -#if defined(Q_OS_WINPHONE) && defined(__ARM__) +#if (defined(Q_OS_WINPHONE) || defined(Q_OS_WINRT)) && defined(__ARM__) # pragma optimize("", on) #endif diff --git a/src/websockets/qwebsockethandshakerequest.cpp b/src/websockets/qwebsockethandshakerequest.cpp index 47586a7..528cb32 100644 --- a/src/websockets/qwebsockethandshakerequest.cpp +++ b/src/websockets/qwebsockethandshakerequest.cpp @@ -222,10 +222,22 @@ void QWebSocketHandshakeRequest::readHandshake(QTextStream &textStream) headerLine = textStream.readLine(); } - const QString host = m_headers.value(QStringLiteral("host"), QString()); m_requestUrl = QUrl::fromEncoded(resourceName.toLatin1()); - if (m_requestUrl.isRelative()) + QString host = m_headers.value(QStringLiteral("host"), QString()); + if (m_requestUrl.isRelative()) { + // see http://tools.ietf.org/html/rfc6455#page-17 + // No. 4 item in "The requirements for this handshake" + int idx = host.indexOf(QStringLiteral(":")); + bool ok = false; + int port = 0; + if (idx != -1) { + port = host.rightRef(host.length() - idx - 1).toInt(&ok); + host.truncate(idx); + } m_requestUrl.setHost(host); + if (ok) + m_requestUrl.setPort(port); + } if (m_requestUrl.scheme().isEmpty()) { const QString scheme = isSecure() ? QStringLiteral("wss") : QStringLiteral("ws"); m_requestUrl.setScheme(scheme); @@ -260,7 +272,7 @@ void QWebSocketHandshakeRequest::readHandshake(QTextStream &textStream) connectionValues << (*c).trimmed(); //optional headers - m_origin = m_headers.value(QStringLiteral("sec-websocket-origin"), QString()); + 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); |