Set an origin header in websocket and http clients
This commit is contained in:
parent
eb9a7bed76
commit
4027f9282b
@ -209,6 +209,12 @@ namespace ix
|
|||||||
ss << "User-Agent: " << userAgent() << "\r\n";
|
ss << "User-Agent: " << userAgent() << "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set an origin header if missing
|
||||||
|
if (args->extraHeaders.find("Origin") == args->extraHeaders.end())
|
||||||
|
{
|
||||||
|
ss << "Origin: " << protocol << "://" << host << ":" << port << "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (verb == kPost || verb == kPut || verb == kPatch || _forceBody)
|
if (verb == kPost || verb == kPut || verb == kPatch || _forceBody)
|
||||||
{
|
{
|
||||||
// Set request compression header
|
// Set request compression header
|
||||||
|
@ -87,6 +87,7 @@ namespace ix
|
|||||||
WebSocketInitResult WebSocketHandshake::clientHandshake(
|
WebSocketInitResult WebSocketHandshake::clientHandshake(
|
||||||
const std::string& url,
|
const std::string& url,
|
||||||
const WebSocketHttpHeaders& extraHeaders,
|
const WebSocketHttpHeaders& extraHeaders,
|
||||||
|
const std::string& protocol,
|
||||||
const std::string& host,
|
const std::string& host,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
int port,
|
int port,
|
||||||
@ -125,6 +126,12 @@ namespace ix
|
|||||||
ss << "User-Agent: " << userAgent() << "\r\n";
|
ss << "User-Agent: " << userAgent() << "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set an origin header if missing
|
||||||
|
if (extraHeaders.find("Origin") == extraHeaders.end())
|
||||||
|
{
|
||||||
|
ss << "Origin: " << protocol << "://" << host << ":" << port << "\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
for (auto& it : extraHeaders)
|
for (auto& it : extraHeaders)
|
||||||
{
|
{
|
||||||
ss << it.first << ": " << it.second << "\r\n";
|
ss << it.first << ": " << it.second << "\r\n";
|
||||||
|
@ -31,6 +31,7 @@ namespace ix
|
|||||||
|
|
||||||
WebSocketInitResult clientHandshake(const std::string& url,
|
WebSocketInitResult clientHandshake(const std::string& url,
|
||||||
const WebSocketHttpHeaders& extraHeaders,
|
const WebSocketHttpHeaders& extraHeaders,
|
||||||
|
const std::string& protocol,
|
||||||
const std::string& host,
|
const std::string& host,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
int port,
|
int port,
|
||||||
|
@ -140,7 +140,7 @@ namespace ix
|
|||||||
_enablePerMessageDeflate);
|
_enablePerMessageDeflate);
|
||||||
|
|
||||||
result = webSocketHandshake.clientHandshake(
|
result = webSocketHandshake.clientHandshake(
|
||||||
remoteUrl, headers, host, path, port, timeoutSecs);
|
remoteUrl, headers, protocol, host, path, port, timeoutSecs);
|
||||||
|
|
||||||
if (result.http_status >= 300 && result.http_status < 400)
|
if (result.http_status >= 300 && result.http_status < 400)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user