diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-02-20 15:38:55 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2015-02-20 15:38:55 +0100 |
commit | b797778da01f72e64cda8680f29f3fa8434ffb0a (patch) | |
tree | a917f080b40188e8f937a50b29e47898e9709a51 /src | |
parent | a834ce5889dc3a79eebe1ac0a1576603b68f5a4b (diff) | |
parent | 85a8ea105646c7d871f982b890ef5f6faa91824d (diff) | |
download | qtwebsockets-b797778da01f72e64cda8680f29f3fa8434ffb0a.tar.gz |
Merge remote-tracking branch 'origin/5.4' into 5.5
Change-Id: I96657102802860c8490c162462324e661592d879
Diffstat (limited to 'src')
-rw-r--r-- | src/websockets/doc/qtwebsockets.qdocconf | 6 | ||||
-rw-r--r-- | src/websockets/qwebsockethandshakerequest.cpp | 18 |
2 files changed, 20 insertions, 4 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/qwebsockethandshakerequest.cpp b/src/websockets/qwebsockethandshakerequest.cpp index 2476a81..6c8c9cf 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(":"); + bool ok = false; + int port; + 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); |