From 0b951ce146f31a8bd4f7e27ba05051387666ebdc Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Tue, 20 Jun 2023 13:32:14 +0200 Subject: [PATCH] Set correct content-type for JSON-RPC --- ethers/providers/jsonrpc.nim | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ethers/providers/jsonrpc.nim b/ethers/providers/jsonrpc.nim index d9f29ce..d80f5fc 100644 --- a/ethers/providers/jsonrpc.nim +++ b/ethers/providers/jsonrpc.nim @@ -50,14 +50,17 @@ template convertError(body) = const defaultUrl = "http://localhost:8545" +proc jsonHeaders: seq[(string, string)] = + @[("Content-Type", "application/json")] + proc connect(_: type RpcClient, url: string): Future[RpcClient] {.async.} = case parseUri(url).scheme of "ws", "wss": - let client = newRpcWebSocketClient() + let client = newRpcWebSocketClient(getHeaders = jsonHeaders) await client.connect(url) return client else: - let client = newRpcHttpClient() + let client = newRpcHttpClient(getHeaders = jsonHeaders) await client.connect(url) return client