ws connect has a new option to send HTTP headers + use WebSocketHttpHeaders instead of unordered_map<string, string>
This commit is contained in:
@ -70,7 +70,7 @@ namespace ix
|
||||
std::lock_guard<std::mutex> lock(_configMutex);
|
||||
_url = url;
|
||||
}
|
||||
void WebSocket::setExtraHeaders(const std::unordered_map<std::string, std::string>& headers)
|
||||
void WebSocket::setExtraHeaders(const WebSocketHttpHeaders& headers)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_configMutex);
|
||||
_extraHeaders = headers;
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace ix
|
||||
{
|
||||
@ -45,8 +44,9 @@ namespace ix
|
||||
~WebSocket();
|
||||
|
||||
void setUrl(const std::string& url);
|
||||
void setExtraHeaders(const std::unordered_map<std::string, std::string>&
|
||||
headers); // send extra headers in client handshake request
|
||||
|
||||
// send extra headers in client handshake request
|
||||
void setExtraHeaders(const WebSocketHttpHeaders& headers);
|
||||
void setPerMessageDeflateOptions(
|
||||
const WebSocketPerMessageDeflateOptions& perMessageDeflateOptions);
|
||||
void setHeartBeatPeriod(int heartBeatPeriodSecs);
|
||||
@ -114,7 +114,7 @@ namespace ix
|
||||
WebSocketTransport _ws;
|
||||
|
||||
std::string _url;
|
||||
std::unordered_map<std::string, std::string> _extraHeaders;
|
||||
WebSocketHttpHeaders _extraHeaders;
|
||||
|
||||
WebSocketPerMessageDeflateOptions _perMessageDeflateOptions;
|
||||
mutable std::mutex _configMutex; // protect all config variables access
|
||||
|
@ -88,7 +88,7 @@ namespace ix
|
||||
}
|
||||
|
||||
WebSocketInitResult WebSocketHandshake::clientHandshake(const std::string& url,
|
||||
const std::unordered_map<std::string, std::string>& extraHeaders,
|
||||
const WebSocketHttpHeaders& extraHeaders,
|
||||
const std::string& host,
|
||||
const std::string& path,
|
||||
int port,
|
||||
|
@ -53,7 +53,7 @@ namespace ix
|
||||
|
||||
WebSocketInitResult clientHandshake(
|
||||
const std::string& url,
|
||||
const std::unordered_map<std::string, std::string>& extraHeaders,
|
||||
const WebSocketHttpHeaders& extraHeaders,
|
||||
const std::string& host,
|
||||
const std::string& path,
|
||||
int port,
|
||||
|
@ -129,7 +129,7 @@ namespace ix
|
||||
// Client
|
||||
WebSocketInitResult WebSocketTransport::connectToUrl(
|
||||
const std::string& url,
|
||||
const std::unordered_map<std::string, std::string>& headers,
|
||||
const WebSocketHttpHeaders& headers,
|
||||
int timeoutSecs)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_socketMutex);
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace ix
|
||||
@ -78,7 +78,7 @@ namespace ix
|
||||
|
||||
WebSocketInitResult connectToUrl( // Client
|
||||
const std::string& url,
|
||||
const std::unordered_map<std::string, std::string>& headers,
|
||||
const WebSocketHttpHeaders& headers,
|
||||
int timeoutSecs);
|
||||
WebSocketInitResult connectToSocket(int fd, // Server
|
||||
int timeoutSecs);
|
||||
|
Reference in New Issue
Block a user