mirror of
https://github.com/logos-storage/nim-json-rpc.git
synced 2026-01-07 08:03:07 +00:00
Allow custom headers in ws backend. Set Origin to http://localhost by default
This commit is contained in:
parent
af33cb9fbc
commit
881c62ed54
@ -45,8 +45,15 @@ proc processData(client: RpcWebSocketClient) {.async.} =
|
||||
# async loop reconnection and waiting
|
||||
client.transport = await newWebSocket(client.uri)
|
||||
|
||||
proc connect*(client: RpcWebSocketClient, uri: string) {.async.} =
|
||||
client.transport = await newWebSocket(uri)
|
||||
proc connect*(client: RpcWebSocketClient, uri: string, headers: StringTableRef = nil) {.async.} =
|
||||
var headers = headers
|
||||
if headers.isNil:
|
||||
headers = newStringTable({"Origin": "http://localhost"})
|
||||
elif "Origin" notin headers:
|
||||
# TODO: This is a hack, because the table might be case sensitive. Ideally strtabs module has
|
||||
# to be extended with case insensitive accessors.
|
||||
headers["Origin"] = "http://localhost"
|
||||
client.transport = await newWebSocket(uri, headers)
|
||||
client.uri = uri
|
||||
client.loop = processData(client)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user