"Host" header override (#87)

Override "Host" header for externally resolved addresses
This commit is contained in:
Dmitriy Ryajov 2021-07-28 11:54:09 -06:00 committed by GitHub
parent d60df8176d
commit 2af07c5736
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -107,6 +107,7 @@ proc connect*(
_: type WebSocket, _: type WebSocket,
host: string | TransportAddress, host: string | TransportAddress,
path: string, path: string,
hostName: string = "", # override used when the hostname has been externally resolved
protocols: seq[string] = @[], protocols: seq[string] = @[],
factories: seq[ExtFactory] = @[], factories: seq[ExtFactory] = @[],
secure = false, secure = false,
@ -133,7 +134,7 @@ proc connect*(
("Cache-Control", "no-cache"), ("Cache-Control", "no-cache"),
("Sec-WebSocket-Version", $version), ("Sec-WebSocket-Version", $version),
("Sec-WebSocket-Key", key), ("Sec-WebSocket-Key", key),
("Host", $host)] ("Host", if hostName.len > 0: hostName else: $host)]
var headers = HttpTable.init(headerData) var headers = HttpTable.init(headerData)
if protocols.len > 0: if protocols.len > 0: