From cae23c764fde6df44abe9a83c0496452d4370399 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Wed, 4 Sep 2019 18:23:56 -0700 Subject: [PATCH] Fragmentation: for sent messages which are compressed, the continuation fragments should not have the rsv1 bit set (fix all autobahn tests for zlib compression 12.X) Websocket Server / do a case insensitive string search when looking for an Upgrade header whose value is websocket. (some client use WebSocket with some upper-case characters) --- DOCKER_VERSION | 2 +- docs/CHANGELOG.md | 5 +++++ ixwebsocket/IXWebSocketHandshake.cpp | 3 ++- ixwebsocket/IXWebSocketTransport.cpp | 7 +++++-- ixwebsocket/IXWebSocketVersion.h | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/DOCKER_VERSION b/DOCKER_VERSION index fc3aa773..91ff5727 100644 --- a/DOCKER_VERSION +++ b/DOCKER_VERSION @@ -1 +1 @@ -5.1.9 +5.2.0 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 49a72a9f..0f0fe8b5 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog All notable changes to this project will be documented in this file. +## [5.2.0] - 2019-09-04 + +- Fragmentation: for sent messages which are compressed, the continuation fragments should not have the rsv1 bit set (fix all autobahn tests for zlib compression 12.X) +- Websocket Server / do a case insensitive string search when looking for an Upgrade header whose value is websocket. (some client use WebSocket with some upper-case characters) + ## [5.1.9] - 2019-09-03 - ws autobahn / report progress with spdlog::info to get timing info diff --git a/ixwebsocket/IXWebSocketHandshake.cpp b/ixwebsocket/IXWebSocketHandshake.cpp index 11529449..f699a0dc 100644 --- a/ixwebsocket/IXWebSocketHandshake.cpp +++ b/ixwebsocket/IXWebSocketHandshake.cpp @@ -295,7 +295,7 @@ namespace ix return sendErrorResponse(400, "Missing Sec-WebSocket-Key value"); } - if (headers["upgrade"] != "websocket") + if (!insensitiveStringCompare(headers["upgrade"], "WebSocket")) { return sendErrorResponse(400, "Invalid or missing Upgrade header"); } @@ -326,6 +326,7 @@ namespace ix ss << "Sec-WebSocket-Accept: " << std::string(output) << "\r\n"; ss << "Upgrade: websocket\r\n"; ss << "Connection: Upgrade\r\n"; + ss << "Server: " << userAgent() << "\r\n"; // Parse the client headers. Does it support deflate ? std::string header = headers["sec-websocket-extensions"]; diff --git a/ixwebsocket/IXWebSocketTransport.cpp b/ixwebsocket/IXWebSocketTransport.cpp index 0a0bc152..3fe2e74e 100644 --- a/ixwebsocket/IXWebSocketTransport.cpp +++ b/ixwebsocket/IXWebSocketTransport.cpp @@ -866,6 +866,8 @@ namespace ix message_end = compressedMessage.end(); } + _txbuf.reserve(wireSize); + // Common case for most message. No fragmentation required. if (wireSize < kChunkSize) { @@ -953,8 +955,9 @@ namespace ix header[0] |= 0x80; } - // This bit indicate that the frame is compressed - if (compress) + // The rsv1 bit indicate that the frame is compressed + // continuation opcodes should not set it. Autobahn 12.2.10 and others 12.X + if (compress && type != wsheader_type::CONTINUATION) { header[0] |= 0x40; } diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index c08c631d..31fba011 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "5.1.9" +#define IX_WEBSOCKET_VERSION "5.2.0"