Message type (TEXT or BINARY) is invalid for received fragmented messages (fix autobahn test: 5.3 through 5.8 Fragmentation)

This commit is contained in:
Benjamin Sergeant 2019-09-03 09:13:38 -07:00
parent a32bf885ba
commit 82213fd3a5
5 changed files with 23 additions and 10 deletions

View File

@ -1 +1 @@
5.1.2
5.1.3

View File

@ -1,13 +1,17 @@
# Changelog
All notable changes to this project will be documented in this file.
## [5.1.3] - 2019-09-03
Message type (TEXT or BINARY) is invalid for received fragmented messages (fix autobahn test: 5.3 through 5.8 Fragmentation)
## [5.1.2] - 2019-09-02
Ping and Pong messages cannot be fragmented (autobahn test: 5.1 and 5.2 Fragmentation)
Ping and Pong messages cannot be fragmented (fix autobahn test: 5.1 and 5.2 Fragmentation)
## [5.1.1] - 2019-09-01
Close connections when reserved bits are used (autobahn test: 3 Reserved Bits)
Close connections when reserved bits are used (fix autobahn test: 3.X Reserved Bits)
## [5.1.0] - 2019-08-31

View File

@ -565,17 +565,20 @@ namespace ix
) {
unmaskReceiveBuffer(ws);
MessageKind messageKind =
(ws.opcode == wsheader_type::TEXT_FRAME)
? MessageKind::MSG_TEXT
: MessageKind::MSG_BINARY;
if (ws.opcode != wsheader_type::CONTINUATION)
{
_fragmentedMessageKind =
(ws.opcode == wsheader_type::TEXT_FRAME)
? MessageKind::MSG_TEXT
: MessageKind::MSG_BINARY;
}
//
// Usual case. Small unfragmented messages
//
if (ws.fin && _chunks.empty())
{
emitMessage(messageKind,
emitMessage(_fragmentedMessageKind,
std::string(_rxbuf.begin()+ws.header_size,
_rxbuf.begin()+ws.header_size+(size_t) ws.N),
ws,
@ -595,7 +598,8 @@ namespace ix
_rxbuf.begin()+ws.header_size+(size_t)ws.N));
if (ws.fin)
{
emitMessage(messageKind, getMergedChunks(), ws, onMessageCallback);
emitMessage(_fragmentedMessageKind, getMergedChunks(),
ws, onMessageCallback);
_chunks.clear();
}
else

View File

@ -151,6 +151,11 @@ namespace ix
// size increased 2 fold, while appending to a list has a fixed cost.
std::list<std::vector<uint8_t>> _chunks;
// Record the message kind (will be TEXT or BINARY) for a fragmented
// message, present in the first chunk, since the final chunk will be a
// CONTINUATION opcode and doesn't tell the full message kind
MessageKind _fragmentedMessageKind;
// Fragments are 32K long
static constexpr size_t kChunkSize = 1 << 15;

View File

@ -6,4 +6,4 @@
#pragma once
#define IX_WEBSOCKET_VERSION "5.1.2"
#define IX_WEBSOCKET_VERSION "5.1.3"