56 lines
2.9 KiB
Diff
56 lines
2.9 KiB
Diff
From 4ab766863d88a491f91fa81731dbde75d0122d89 Mon Sep 17 00:00:00 2001
|
|
From: Timur Pocheptsov <timur.pocheptsov@qt.io>
|
|
Date: Mon, 14 May 2018 12:41:23 +0200
|
|
Subject: [PATCH] Use QUrl::toString() when forming the 'Host' header
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
This allows to correctly use IPv6 literals and also
|
|
deals (correctly) with a port (if it's set at all).
|
|
|
|
Task-number: QTBUG-68245
|
|
Change-Id: I6d29543887c4ab58d70f0970a6f0a1b822c301df
|
|
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
|
|
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
|
|
---
|
|
src/websockets/qwebsocket_p.cpp | 22 ++++++++++++----------
|
|
1 file changed, 12 insertions(+), 10 deletions(-)
|
|
|
|
diff --git x/qtwebsockets/src/websockets/qwebsocket_p.cpp y/qtwebsockets/src/websockets/qwebsocket_p.cpp
|
|
index d233b66..9b27ad2 100644
|
|
--- x/qtwebsockets/src/websockets/qwebsocket_p.cpp
|
|
+++ y/qtwebsockets/src/websockets/qwebsocket_p.cpp
|
|
@@ -1108,16 +1108,18 @@ void QWebSocketPrivate::processStateChanged(QAbstractSocket::SocketState socketS
|
|
headers << qMakePair(QString::fromLatin1(key),
|
|
QString::fromLatin1(m_request.rawHeader(key)));
|
|
|
|
- const QString handshake =
|
|
- createHandShakeRequest(m_resourceName,
|
|
- m_request.url().host()
|
|
- % QStringLiteral(":")
|
|
- % QString::number(m_request.url().port(port)),
|
|
- origin(),
|
|
- QString(),
|
|
- QString(),
|
|
- m_key,
|
|
- headers);
|
|
+ const auto format = QUrl::RemoveScheme | QUrl::RemoveUserInfo
|
|
+ | QUrl::RemovePath | QUrl::RemoveQuery
|
|
+ | QUrl::RemoveFragment | QUrl::RemovePort;
|
|
+ const QString host = m_request.url().toString(format).mid(2);
|
|
+ const QString handshake = createHandShakeRequest(m_resourceName,
|
|
+ host % QStringLiteral(":")
|
|
+ % QString::number(m_request.url().port(port)),
|
|
+ origin(),
|
|
+ QString(),
|
|
+ QString(),
|
|
+ m_key,
|
|
+ headers);
|
|
if (handshake.isEmpty()) {
|
|
m_pSocket->abort();
|
|
Q_EMIT q->error(QAbstractSocket::ConnectionRefusedError);
|
|
--
|
|
2.19.0
|
|
|