summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/websockets/qwebsocketframe.cpp54
-rw-r--r--src/websockets/qwebsocketframe_p.h15
-rw-r--r--tests/auto/websockets/websocketframe/tst_websocketframe.cpp32
3 files changed, 38 insertions, 63 deletions
diff --git a/src/websockets/qwebsocketframe.cpp b/src/websockets/qwebsocketframe.cpp
index d533921..b76fa5c 100644
--- a/src/websockets/qwebsocketframe.cpp
+++ b/src/websockets/qwebsocketframe.cpp
@@ -61,14 +61,14 @@ QT_BEGIN_NAMESPACE
QWebSocketFrame::QWebSocketFrame() :
m_closeCode(QWebSocketProtocol::CloseCodeNormal),
m_closeReason(),
- m_isFinalFrame(true),
m_mask(0),
- m_rsv1(0),
- m_rsv2(0),
- m_rsv3(0),
m_opCode(QWebSocketProtocol::OpCodeReservedC),
m_length(0),
m_payload(),
+ m_isFinalFrame(true),
+ m_rsv1(false),
+ m_rsv2(false),
+ m_rsv3(false),
m_isValid(false)
{
}
@@ -79,14 +79,14 @@ QWebSocketFrame::QWebSocketFrame() :
QWebSocketFrame::QWebSocketFrame(const QWebSocketFrame &other) :
m_closeCode(other.m_closeCode),
m_closeReason(other.m_closeReason),
- m_isFinalFrame(other.m_isFinalFrame),
m_mask(other.m_mask),
- m_rsv1(other.m_rsv1),
- m_rsv2(other.m_rsv2),
- m_rsv3(other.m_rsv3),
m_opCode(other.m_opCode),
m_length(other.m_length),
m_payload(other.m_payload),
+ m_isFinalFrame(other.m_isFinalFrame),
+ m_rsv1(other.m_rsv1),
+ m_rsv2(other.m_rsv2),
+ m_rsv3(other.m_rsv3),
m_isValid(other.m_isValid)
{
}
@@ -118,14 +118,14 @@ QWebSocketFrame &QWebSocketFrame::operator =(const QWebSocketFrame &other)
QWebSocketFrame::QWebSocketFrame(QWebSocketFrame &&other) :
m_closeCode(qMove(other.m_closeCode)),
m_closeReason(qMove(other.m_closeReason)),
- m_isFinalFrame(qMove(other.m_isFinalFrame)),
m_mask(qMove(other.m_mask)),
- m_rsv1(qMove(other.m_rsv1)),
- m_rsv2(qMove(other.m_rsv2)),
- m_rsv3(qMove(other.m_rsv3)),
m_opCode(qMove(other.m_opCode)),
m_length(qMove(other.m_length)),
m_payload(qMove(other.m_payload)),
+ m_isFinalFrame(qMove(other.m_isFinalFrame)),
+ m_rsv1(qMove(other.m_rsv1)),
+ m_rsv2(qMove(other.m_rsv2)),
+ m_rsv3(qMove(other.m_rsv3)),
m_isValid(qMove(other.m_isValid))
{}
@@ -239,30 +239,6 @@ quint32 QWebSocketFrame::mask() const
/*!
\internal
*/
-int QWebSocketFrame::rsv1() const
-{
- return m_rsv1;
-}
-
-/*!
- \internal
- */
-int QWebSocketFrame::rsv2() const
-{
- return m_rsv2;
-}
-
-/*!
- \internal
- */
-int QWebSocketFrame::rsv3() const
-{
- return m_rsv3;
-}
-
-/*!
- \internal
- */
QWebSocketProtocol::OpCode QWebSocketFrame::opCode() const
{
return m_opCode;
@@ -287,9 +263,9 @@ void QWebSocketFrame::clear()
m_closeReason.clear();
m_isFinalFrame = true;
m_mask = 0;
- m_rsv1 = 0;
- m_rsv2 = 0;
- m_rsv3 = 0;
+ m_rsv1 = false;
+ m_rsv2 = false;
+ m_rsv3 = false;
m_opCode = QWebSocketProtocol::OpCodeReservedC;
m_length = 0;
m_payload.clear();
diff --git a/src/websockets/qwebsocketframe_p.h b/src/websockets/qwebsocketframe_p.h
index 131775b..b0c1ab2 100644
--- a/src/websockets/qwebsocketframe_p.h
+++ b/src/websockets/qwebsocketframe_p.h
@@ -75,9 +75,9 @@ public:
bool isContinuationFrame() const;
bool hasMask() const;
quint32 mask() const; //returns 0 if no mask
- int rsv1() const;
- int rsv2() const;
- int rsv3() const;
+ inline bool rsv1() const { return m_rsv1; }
+ inline bool rsv2() const { return m_rsv2; }
+ inline bool rsv3() const { return m_rsv3; }
QWebSocketProtocol::OpCode opCode() const;
QByteArray payload() const;
@@ -90,16 +90,15 @@ public:
private:
QWebSocketProtocol::CloseCode m_closeCode;
QString m_closeReason;
- bool m_isFinalFrame;
quint32 m_mask;
- int m_rsv1;
- int m_rsv2;
- int m_rsv3;
QWebSocketProtocol::OpCode m_opCode;
-
quint8 m_length;
QByteArray m_payload;
+ bool m_isFinalFrame;
+ bool m_rsv1;
+ bool m_rsv2;
+ bool m_rsv3;
bool m_isValid;
enum ProcessingState
diff --git a/tests/auto/websockets/websocketframe/tst_websocketframe.cpp b/tests/auto/websockets/websocketframe/tst_websocketframe.cpp
index 5db82d5..ecfcf3b 100644
--- a/tests/auto/websockets/websocketframe/tst_websocketframe.cpp
+++ b/tests/auto/websockets/websocketframe/tst_websocketframe.cpp
@@ -244,9 +244,9 @@ void tst_WebSocketFrame::tst_copyConstructorAndAssignment()
void tst_WebSocketFrame::tst_goodFrames_data()
{
- QTest::addColumn<int>("rsv1");
- QTest::addColumn<int>("rsv2");
- QTest::addColumn<int>("rsv3");
+ QTest::addColumn<bool>("rsv1");
+ QTest::addColumn<bool>("rsv2");
+ QTest::addColumn<bool>("rsv3");
QTest::addColumn<quint32>("mask");
QTest::addColumn<QWebSocketProtocol::OpCode>("opCode");
QTest::addColumn<bool>("isFinal");
@@ -256,54 +256,54 @@ void tst_WebSocketFrame::tst_goodFrames_data()
QTest::addColumn<bool>("isContinuationFrame");
QTest::newRow("Non masked final text frame with small payload")
- << 0 << 0 << 0
+ << false << false << false
<< 0U << QWebSocketProtocol::OpCodeText
<< true << QStringLiteral("Hello world!").toUtf8()
<< false << true << false;
QTest::newRow("Non masked final binary frame with small payload")
- << 0 << 0 << 0
+ << false << false << false
<< 0U << QWebSocketProtocol::OpCodeBinary
<< true << QByteArrayLiteral("\x00\x01\x02\x03\x04")
<< false << true << false;
QTest::newRow("Non masked final text frame with no payload")
- << 0 << 0 << 0
+ << false << false << false
<< 0U << QWebSocketProtocol::OpCodeText
<< true << QByteArray()
<< false << true << false;
QTest::newRow("Non masked final binary frame with no payload")
- << 0 << 0 << 0
+ << false << false << false
<< 0U << QWebSocketProtocol::OpCodeBinary
<< true << QByteArray()
<< false << true << false;
QTest::newRow("Non masked final close frame with small payload")
- << 0 << 0 << 0
+ << false << false << false
<< 0U << QWebSocketProtocol::OpCodeClose
<< true << QStringLiteral("Hello world!").toUtf8()
<< true << false << false;
QTest::newRow("Non masked final close frame with no payload")
- << 0 << 0 << 0
+ << false << false << false
<< 0U << QWebSocketProtocol::OpCodeClose
<< true << QByteArray()
<< true << false << false;
QTest::newRow("Non masked final ping frame with small payload")
- << 0 << 0 << 0
+ << false << false << false
<< 0U << QWebSocketProtocol::OpCodePing
<< true << QStringLiteral("Hello world!").toUtf8()
<< true << false << false;
QTest::newRow("Non masked final pong frame with no payload")
- << 0 << 0 << 0
+ << false << false << false
<< 0U << QWebSocketProtocol::OpCodePong
<< true << QByteArray()
<< true << false << false;
QTest::newRow("Non masked final continuation frame with small payload")
- << 0 << 0 << 0
+ << false << false << false
<< 0U << QWebSocketProtocol::OpCodeContinue
<< true << QStringLiteral("Hello world!").toUtf8()
<< false << true << true;
QTest::newRow("Non masked non-final continuation frame with small payload")
- << 0 << 0 << 0
+ << false << false << false
<< 0U << QWebSocketProtocol::OpCodeContinue
<< false << QStringLiteral("Hello world!").toUtf8()
<< false << true << true;
@@ -311,9 +311,9 @@ void tst_WebSocketFrame::tst_goodFrames_data()
void tst_WebSocketFrame::tst_goodFrames()
{
- QFETCH(int, rsv1);
- QFETCH(int, rsv2);
- QFETCH(int, rsv3);
+ QFETCH(bool, rsv1);
+ QFETCH(bool, rsv2);
+ QFETCH(bool, rsv3);
QFETCH(quint32, mask);
QFETCH(QWebSocketProtocol::OpCode, opCode);
QFETCH(bool, isFinal);