Skip to main content

build_http_client

Function build_http_client 

Source
pub fn build_http_client(timeout: Duration) -> Result<Client, String>
Expand description

Build an HTTP client with the given timeout.

Honors the Tor failsafe: when the user has Tor enabled, every connection goes through Tor — period. If Tor is enabled but not currently running (bootstrap in flight, mid-restart, service crashed), the returned client is wired to a blackhole SOCKS proxy so requests fail at the TCP layer without any chance of leaking clearnet traffic. Direct connections are only ever issued when the user has explicitly disabled Tor.

Callers should use this rather than reqwest::Client::builder() directly so the failsafe automatically covers their traffic. The disallowed_methods clippy lint enforces this everywhere except this one canonical call site.