diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 058bf82f..ac70b82b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,10 @@ All changes to this project will be documented in this file. +## [10.4.1] - 2020-09-18 + +(cobra connection and bots) set an HTTP header when connecting to help with debugging bots + ## [10.4.0] - 2020-09-12 (http server) read body request when the Content-Length is specified + set timeout to read the request to 30 seconds max by default, and make it configurable as a constructor parameter diff --git a/ixbots/ixbots/IXCobraBot.cpp b/ixbots/ixbots/IXCobraBot.cpp index b2a80bd6..b221b585 100644 --- a/ixbots/ixbots/IXCobraBot.cpp +++ b/ixbots/ixbots/IXCobraBot.cpp @@ -31,6 +31,8 @@ namespace ix auto limitReceivedEvents = botConfig.limitReceivedEvents; auto batchSize = botConfig.batchSize; + config.headers["X-Cobra-Channel"] = channel; + ix::CobraConnection conn; conn.configure(config); conn.connect(); diff --git a/ixcobra/ixcobra/IXCobraConfig.h b/ixcobra/ixcobra/IXCobraConfig.h index 26b85e41..ccf95653 100644 --- a/ixcobra/ixcobra/IXCobraConfig.h +++ b/ixcobra/ixcobra/IXCobraConfig.h @@ -8,6 +8,7 @@ #include #include +#include namespace ix { @@ -19,6 +20,7 @@ namespace ix std::string rolesecret; WebSocketPerMessageDeflateOptions webSocketPerMessageDeflateOptions; SocketTLSOptions socketTLSOptions; + WebSocketHttpHeaders headers; CobraConfig(const std::string& a = std::string(), const std::string& e = std::string(), diff --git a/ixcobra/ixcobra/IXCobraConnection.cpp b/ixcobra/ixcobra/IXCobraConnection.cpp index 523993c2..02de9c2b 100644 --- a/ixcobra/ixcobra/IXCobraConnection.cpp +++ b/ixcobra/ixcobra/IXCobraConnection.cpp @@ -255,7 +255,8 @@ namespace ix const std::string& rolename, const std::string& rolesecret, const WebSocketPerMessageDeflateOptions& webSocketPerMessageDeflateOptions, - const SocketTLSOptions& socketTLSOptions) + const SocketTLSOptions& socketTLSOptions, + const WebSocketHttpHeaders& headers) { _roleName = rolename; _roleSecret = rolesecret; @@ -269,6 +270,7 @@ namespace ix _webSocket->setUrl(url); _webSocket->setPerMessageDeflateOptions(webSocketPerMessageDeflateOptions); _webSocket->setTLSOptions(socketTLSOptions); + _webSocket->setExtraHeaders(headers); // Send a websocket ping every N seconds (N = 30) now // This should keep the connection open and prevent some load balancers such as @@ -283,7 +285,8 @@ namespace ix config.rolename, config.rolesecret, config.webSocketPerMessageDeflateOptions, - config.socketTLSOptions); + config.socketTLSOptions, + config.headers); } // diff --git a/ixcobra/ixcobra/IXCobraConnection.h b/ixcobra/ixcobra/IXCobraConnection.h index 66d5df9a..ea4a7863 100644 --- a/ixcobra/ixcobra/IXCobraConnection.h +++ b/ixcobra/ixcobra/IXCobraConnection.h @@ -56,7 +56,8 @@ namespace ix const std::string& rolename, const std::string& rolesecret, const WebSocketPerMessageDeflateOptions& webSocketPerMessageDeflateOptions, - const SocketTLSOptions& socketTLSOptions); + const SocketTLSOptions& socketTLSOptions, + const WebSocketHttpHeaders& headers); void configure(const ix::CobraConfig& config); diff --git a/ixwebsocket/IXWebSocket.cpp b/ixwebsocket/IXWebSocket.cpp index c3c42135..6d27e7f9 100644 --- a/ixwebsocket/IXWebSocket.cpp +++ b/ixwebsocket/IXWebSocket.cpp @@ -54,6 +54,7 @@ namespace ix std::lock_guard lock(_configMutex); _url = url; } + void WebSocket::setExtraHeaders(const WebSocketHttpHeaders& headers) { std::lock_guard lock(_configMutex); diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index 71da73c3..b88a3303 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "10.4.0" +#define IX_WEBSOCKET_VERSION "10.4.1"