aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@qt.io>2018-03-20 10:00:13 +0100
committerMorten Johan Sørvig <morten.sorvig@qt.io>2018-03-22 16:30:49 +0000
commitbcea7a1a8b46aa1e9e5fcf3e43bd251360cf8634 (patch)
tree0c3832bff560329ff78c1f3da1bd3e220b3a1fa9
parent8a549aca7b371722cbf012d85216e4560ef1cf33 (diff)
Make QWebSocketServer work with Safariv5.11.0-beta3
Sending an empty “Server” header during handshake will make Safari error out with “WebSocket connection [...] failed: Invalid UTF-8 sequence in header value” This is an open bug in WebKit: https://bugs.webkit.org/show_bug.cgi?id=139298 As far as I see, “Server” is not a required handshake header as specified in RFC 6455 section 4.2.2 (5), and we can omit it if the server name is not set. Change-Id: Icec142f867813c16e3e3baa1378582164242e049 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r--src/websockets/qwebsockethandshakeresponse.cpp5
-rw-r--r--src/websockets/qwebsocketserver.cpp2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/websockets/qwebsockethandshakeresponse.cpp b/src/websockets/qwebsockethandshakeresponse.cpp
index ee57d5c..2241ca2 100644
--- a/src/websockets/qwebsockethandshakeresponse.cpp
+++ b/src/websockets/qwebsockethandshakeresponse.cpp
@@ -186,8 +186,9 @@ QString QWebSocketHandshakeResponse::getHandshakeResponse(
if (origin.isEmpty())
origin = QStringLiteral("*");
QDateTime datetime = QDateTime::currentDateTimeUtc();
- response << QStringLiteral("Server: ") % serverName <<
- QStringLiteral("Access-Control-Allow-Credentials: false") <<
+ if (!serverName.isEmpty())
+ response << QStringLiteral("Server: ") % serverName;
+ response << QStringLiteral("Access-Control-Allow-Credentials: false") <<
QStringLiteral("Access-Control-Allow-Methods: GET") <<
QStringLiteral("Access-Control-Allow-Headers: content-type") <<
QStringLiteral("Access-Control-Allow-Origin: ") % origin <<
diff --git a/src/websockets/qwebsocketserver.cpp b/src/websockets/qwebsocketserver.cpp
index be66946..5111bfd 100644
--- a/src/websockets/qwebsocketserver.cpp
+++ b/src/websockets/qwebsocketserver.cpp
@@ -241,7 +241,7 @@ QT_BEGIN_NAMESPACE
/*!
Constructs a new QWebSocketServer with the given \a serverName.
The \a serverName will be used in the HTTP handshake phase to identify the server.
- It can be empty, in which case an empty server name will be sent to the client.
+ It can be empty, in which case no server name will be sent to the client.
The \a secureMode parameter indicates whether the server operates over wss (\l{SecureMode})
or over ws (\l{NonSecureMode}).