rust-bitcoin / rust-bitcoincore-rpc

Rust RPC client library for the Bitcoin Core JSON-RPC API.
334 stars 247 forks source link

Ability to set custom headers in HTTP requests #304

Open tomjohnburton opened 1 year ago

tomjohnburton commented 1 year ago

Hello,

I am using the rust-bitcoincore-rpc library in a project where I run a Bitcoin node behind a Traefik reverse proxy for testing purposes. I use the hostname bitcoin.localhost to access the Bitcoin node.

I'm facing an issue when I use this library to send requests to my Bitcoin node. Even though I've mapped bitcoin.localhost to localhost in my /etc/hosts file, it seems that the requests from this library are not being correctly routed to the Bitcoin node by Traefik.

Looking at Traefik's logs, it appears that the HTTP requests sent from this library don't have the Host header set to bitcoin.localhost, which is causing Traefik to not route the requests to the Bitcoin node.

I've tried to set the Host header manually in the library, but it seems that this functionality is not currently supported.

Having the ability to set custom headers in HTTP requests would be very useful in my case, and I think it would also be a good feature to have in the library in general.

Could you please consider adding this functionality, or suggest another workaround to handle my situation?

Thank you for your help and for maintaining this library.

apoelstra commented 1 year ago

I think this properly belongs in rust-jsonrpc, which handles the HTTP transport -- this was recently updated to allow using minreq rather than our own homebrew HTTP server. I think that might cover your use case.

rust-jsonrpc is at https://github.com/apoelstra/rust-jsonrpc/