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 # Changelog
All notable changes to this project will be documented in this file. 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 ## [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 ## [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 ## [5.1.0] - 2019-08-31

View File

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

View File

@ -151,6 +151,11 @@ namespace ix
// size increased 2 fold, while appending to a list has a fixed cost. // size increased 2 fold, while appending to a list has a fixed cost.
std::list<std::vector<uint8_t>> _chunks; 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 // Fragments are 32K long
static constexpr size_t kChunkSize = 1 << 15; static constexpr size_t kChunkSize = 1 << 15;

View File

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