summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2015-01-19 14:08:49 +0100
committerFrederik Gladhorn <frederik.gladhorn@theqtcompany.com>2015-01-19 14:08:49 +0100
commitbb9c22280afea1687b4c8ac012139f23b29adf5a (patch)
tree8450821b96a129db47d30d9b0a75f3509c306f37
parent394b7bc81f3f5109bc0cfd0a86497568ad64f2b6 (diff)
parentcb69a079ed323e3b524e3537b5b6582fd11495a2 (diff)
downloadqtwebsockets-bb9c22280afea1687b4c8ac012139f23b29adf5a.tar.gz
Merge remote-tracking branch 'origin/5.4' into dev
Conflicts: .qmake.conf Change-Id: I6ceee770359e72a026575ea9fee51c3f97561163
-rw-r--r--src/websockets/qwebsocket_p.cpp2
-rw-r--r--tests/auto/qwebsocket/tst_qwebsocket.cpp5
2 files changed, 7 insertions, 0 deletions
diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp
index 7f5251b..ab2fec5 100644
--- a/src/websockets/qwebsocket_p.cpp
+++ b/src/websockets/qwebsocket_p.cpp
@@ -301,6 +301,8 @@ void QWebSocketPrivate::close(QWebSocketProtocol::CloseCode closeCode, QString r
return;
if (!m_isClosingHandshakeSent) {
Q_Q(QWebSocket);
+ m_closeCode = closeCode;
+ m_closeReason = reason;
const quint16 code = qToBigEndian<quint16>(closeCode);
QByteArray payload;
payload.append(static_cast<const char *>(static_cast<const void *>(&code)), 2);
diff --git a/tests/auto/qwebsocket/tst_qwebsocket.cpp b/tests/auto/qwebsocket/tst_qwebsocket.cpp
index dfca947..ba75e3f 100644
--- a/tests/auto/qwebsocket/tst_qwebsocket.cpp
+++ b/tests/auto/qwebsocket/tst_qwebsocket.cpp
@@ -474,6 +474,11 @@ void tst_QWebSocket::tst_sendTextMessage()
isLastFrame = arguments.at(1).toBool();
QCOMPARE(frameReceived, QStringLiteral("Hello world!"));
QVERIFY(isLastFrame);
+
+ QString reason = QStringLiteral("going away");
+ socket.close(QWebSocketProtocol::CloseCodeGoingAway, reason);
+ QCOMPARE(socket.closeCode(), QWebSocketProtocol::CloseCodeGoingAway);
+ QCOMPARE(socket.closeReason(), reason);
#endif
}