summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 f483e12..45913e5 100644
--- a/src/websockets/qwebsocket_p.cpp
+++ b/src/websockets/qwebsocket_p.cpp
@@ -300,6 +300,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 0d1a46d..0e04ce1 100644
--- a/tests/auto/qwebsocket/tst_qwebsocket.cpp
+++ b/tests/auto/qwebsocket/tst_qwebsocket.cpp
@@ -471,6 +471,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
}