Skip to content

Commit cd67863

Browse files
committed
pocoproject#550 WebSocket fragmented message problem
1 parent 84adc73 commit cd67863

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

Net/include/Poco/Net/WebSocket.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class Net_API WebSocket: public StreamSocket
7676
FRAME_OP_CLOSE = 0x08, /// Close connection.
7777
FRAME_OP_PING = 0x09, /// Ping frame.
7878
FRAME_OP_PONG = 0x0a, /// Pong frame.
79-
FRAME_OP_BITMASK = 0x0f /// Bit mask for opcodes.
79+
FRAME_OP_BITMASK = 0x0f, /// Bit mask for opcodes.
80+
FRAME_OP_SETRAW = 0x100 /// Set raw flags (for use with sendBytes() and FRAME_OP_CONT).
8081
};
8182

8283
enum SendFlags

Net/src/WebSocket.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ void WebSocket::shutdown(Poco::UInt16 statusCode, const std::string& statusMessa
101101

102102
int WebSocket::sendFrame(const void* buffer, int length, int flags)
103103
{
104+
flags |= FRAME_OP_SETRAW;
104105
return static_cast<WebSocketImpl*>(impl())->sendBytes(buffer, length, flags);
105106
}
106107

Net/src/WebSocketImpl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ int WebSocketImpl::sendBytes(const void* buffer, int length, int flags)
6161
Poco::BinaryWriter writer(ostr, Poco::BinaryWriter::NETWORK_BYTE_ORDER);
6262

6363
if (flags == 0) flags = WebSocket::FRAME_BINARY;
64+
flags &= 0xff;
6465
writer << static_cast<Poco::UInt8>(flags);
6566
Poco::UInt8 lengthByte(0);
6667
if (_mustMaskPayload)

0 commit comments

Comments
 (0)