Add client handshake extra headers (#105)

Even though 6455 defines all the necessary headers needed for
client/server handshake, in practice most of the cases websocket servers
expect few more headers. Therefore adding this functionality.
This commit is contained in:
ozychhi
2019-08-26 11:37:40 -05:00
committed by Benjamin Sergeant
parent ff75846d2d
commit 93debc00dc
6 changed files with 34 additions and 12 deletions

View File

@@ -88,6 +88,7 @@ namespace ix
}
WebSocketInitResult WebSocketHandshake::clientHandshake(const std::string& url,
const std::unordered_map<std::string, std::string>& extraHeaders,
const std::string& host,
const std::string& path,
int port,
@@ -127,6 +128,9 @@ namespace ix
ss << "Sec-WebSocket-Version: 13\r\n";
ss << "Sec-WebSocket-Key: " << secWebSocketKey << "\r\n";
for (auto& it : extraHeaders) {
ss << it.first << ":" << it.second << "\r\n";
}
if (_enablePerMessageDeflate)
{
ss << _perMessageDeflateOptions.generateHeader();