summaryrefslogtreecommitdiff
path: root/src/websockets/qwebsockethandshakerequest.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-01-25 11:03:47 +0100
committerLiang Qi <liang.qi@qt.io>2017-01-25 11:03:47 +0100
commitdfc91928f15302fa4e6c41802c60caec2c124942 (patch)
tree7c32786f83a45d9d8de8d989e9d54dcc0982d4e5 /src/websockets/qwebsockethandshakerequest.cpp
parenta0aec91b676e2b79b8e66091d55d9e128bf2a1d0 (diff)
parent670266a075c7c312c6a7f9465298bfec0b968ee2 (diff)
downloadqtwebsockets-dfc91928f15302fa4e6c41802c60caec2c124942.tar.gz
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: .qmake.conf Change-Id: If50b73b1f1e293269404bd8b38088119a0f59f1f
Diffstat (limited to 'src/websockets/qwebsockethandshakerequest.cpp')
-rw-r--r--src/websockets/qwebsockethandshakerequest.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/websockets/qwebsockethandshakerequest.cpp b/src/websockets/qwebsockethandshakerequest.cpp
index 81c5f97..ddeee2d 100644
--- a/src/websockets/qwebsockethandshakerequest.cpp
+++ b/src/websockets/qwebsockethandshakerequest.cpp
@@ -275,16 +275,12 @@ void QWebSocketHandshakeRequest::readHandshake(QTextStream &textStream, int maxH
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.setAuthority(host);
+ if (!m_requestUrl.userName().isNull()) { // If the username is null, the password must be too.
+ m_isValid = false;
+ clear();
+ return;
}
- m_requestUrl.setHost(host);
- if (ok)
- m_requestUrl.setPort(port);
}
if (m_requestUrl.scheme().isEmpty()) {
const QString scheme = isSecure() ? QStringLiteral("wss") : QStringLiteral("ws");
@@ -337,7 +333,7 @@ void QWebSocketHandshakeRequest::readHandshake(QTextStream &textStream, int maxH
//TODO: authentication field
- m_isValid = !(host.isEmpty() ||
+ m_isValid = !(m_requestUrl.host().isEmpty() ||
resourceName.isEmpty() ||
m_versions.isEmpty() ||
m_key.isEmpty() ||