(websocket) reset per-message deflate codec everytime we connect to a server/client
This commit is contained in:
parent
f41a54186c
commit
9dcc2538ae
@ -1,6 +1,10 @@
|
||||
# Changelog
|
||||
All changes to this project will be documented in this file.
|
||||
|
||||
## [9.0.0] - 2020-03-23
|
||||
|
||||
(websocket) reset per-message deflate codec everytime we connect to a server/client
|
||||
|
||||
## [8.3.4] - 2020-03-23
|
||||
|
||||
(websocket) fix #167, a long standing issue with sending empty messages with per-message deflate extension (and hopefully other zlib bug)
|
||||
|
@ -22,7 +22,7 @@ namespace ix
|
||||
WebSocketHandshake::WebSocketHandshake(
|
||||
std::atomic<bool>& requestInitCancellation,
|
||||
std::shared_ptr<Socket> socket,
|
||||
WebSocketPerMessageDeflate& perMessageDeflate,
|
||||
WebSocketPerMessageDeflatePtr& perMessageDeflate,
|
||||
WebSocketPerMessageDeflateOptions& perMessageDeflateOptions,
|
||||
std::atomic<bool>& enablePerMessageDeflate)
|
||||
: _requestInitCancellation(requestInitCancellation)
|
||||
@ -230,7 +230,7 @@ namespace ix
|
||||
_enablePerMessageDeflate = false;
|
||||
}
|
||||
// Otherwise try to initialize the deflate engine (zlib)
|
||||
else if (!_perMessageDeflate.init(webSocketPerMessageDeflateOptions))
|
||||
else if (!_perMessageDeflate->init(webSocketPerMessageDeflateOptions))
|
||||
{
|
||||
return WebSocketInitResult(
|
||||
false, 0, "Failed to initialize per message deflate engine");
|
||||
@ -341,7 +341,7 @@ namespace ix
|
||||
{
|
||||
_enablePerMessageDeflate = true;
|
||||
|
||||
if (!_perMessageDeflate.init(webSocketPerMessageDeflateOptions))
|
||||
if (!_perMessageDeflate->init(webSocketPerMessageDeflateOptions))
|
||||
{
|
||||
return WebSocketInitResult(
|
||||
false, 0, "Failed to initialize per message deflate engine");
|
||||
|
@ -24,7 +24,7 @@ namespace ix
|
||||
public:
|
||||
WebSocketHandshake(std::atomic<bool>& requestInitCancellation,
|
||||
std::shared_ptr<Socket> _socket,
|
||||
WebSocketPerMessageDeflate& perMessageDeflate,
|
||||
WebSocketPerMessageDeflatePtr& perMessageDeflate,
|
||||
WebSocketPerMessageDeflateOptions& perMessageDeflateOptions,
|
||||
std::atomic<bool>& enablePerMessageDeflate);
|
||||
|
||||
@ -47,7 +47,7 @@ namespace ix
|
||||
|
||||
std::atomic<bool>& _requestInitCancellation;
|
||||
std::shared_ptr<Socket> _socket;
|
||||
WebSocketPerMessageDeflate& _perMessageDeflate;
|
||||
WebSocketPerMessageDeflatePtr& _perMessageDeflate;
|
||||
WebSocketPerMessageDeflateOptions& _perMessageDeflateOptions;
|
||||
std::atomic<bool>& _enablePerMessageDeflate;
|
||||
};
|
||||
|
@ -57,4 +57,6 @@ namespace ix
|
||||
std::unique_ptr<WebSocketPerMessageDeflateCompressor> _compressor;
|
||||
std::unique_ptr<WebSocketPerMessageDeflateDecompressor> _decompressor;
|
||||
};
|
||||
|
||||
using WebSocketPerMessageDeflatePtr = std::unique_ptr<WebSocketPerMessageDeflate>;
|
||||
} // namespace ix
|
||||
|
@ -117,6 +117,7 @@ namespace ix
|
||||
std::string errorMsg;
|
||||
bool tls = protocol == "wss";
|
||||
_socket = createSocket(tls, -1, errorMsg, _socketTLSOptions);
|
||||
_perMessageDeflate = std::make_unique<WebSocketPerMessageDeflate>();
|
||||
|
||||
if (!_socket)
|
||||
{
|
||||
@ -149,6 +150,7 @@ namespace ix
|
||||
_blockingSend = true;
|
||||
|
||||
_socket = socket;
|
||||
_perMessageDeflate = std::make_unique<WebSocketPerMessageDeflate>();
|
||||
|
||||
WebSocketHandshake webSocketHandshake(_requestInitCancellation,
|
||||
_socket,
|
||||
@ -711,7 +713,7 @@ namespace ix
|
||||
if (compressedMessage && messageKind != MessageKind::FRAGMENT)
|
||||
{
|
||||
std::string decompressedMessage;
|
||||
bool success = _perMessageDeflate.decompress(message, decompressedMessage);
|
||||
bool success = _perMessageDeflate->decompress(message, decompressedMessage);
|
||||
|
||||
if (messageKind == MessageKind::MSG_TEXT && !validateUtf8(decompressedMessage))
|
||||
{
|
||||
@ -765,7 +767,7 @@ namespace ix
|
||||
|
||||
if (compress)
|
||||
{
|
||||
if (!_perMessageDeflate.compress(message, compressedMessage))
|
||||
if (!_perMessageDeflate->compress(message, compressedMessage))
|
||||
{
|
||||
bool success = false;
|
||||
compressionError = true;
|
||||
|
@ -185,7 +185,7 @@ namespace ix
|
||||
mutable std::mutex _closeDataMutex;
|
||||
|
||||
// Data used for Per Message Deflate compression (with zlib)
|
||||
WebSocketPerMessageDeflate _perMessageDeflate;
|
||||
WebSocketPerMessageDeflatePtr _perMessageDeflate;
|
||||
WebSocketPerMessageDeflateOptions _perMessageDeflateOptions;
|
||||
std::atomic<bool> _enablePerMessageDeflate;
|
||||
|
||||
|
@ -6,4 +6,4 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#define IX_WEBSOCKET_VERSION "8.3.4"
|
||||
#define IX_WEBSOCKET_VERSION "9.0.0"
|
||||
|
Loading…
Reference in New Issue
Block a user