MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / get_http_proxy_url

Function get_http_proxy_url

fendermint/rpc/src/client.rs:29–49  ·  view source on GitHub ↗

Retrieve the proxy URL with precedence: 1. If supplied, that's the proxy URL used. 2. If not supplied, but environment variable HTTP_PROXY or HTTPS_PROXY are supplied, then use the appropriate variable for the URL in question. Copied from `tendermint_rpc`.

(url_scheme: Scheme, proxy_url: Option<Url>)

Source from the content-addressed store, hash-verified

27//
28// Copied from `tendermint_rpc`.
29fn get_http_proxy_url(url_scheme: Scheme, proxy_url: Option<Url>) -> anyhow::Result<Option<Url>> {
30 match proxy_url {
31 Some(u) => Ok(Some(u)),
32 None => match url_scheme {
33 Scheme::Http => std::env::var("HTTP_PROXY").ok(),
34 Scheme::Https => std::env::var("HTTPS_PROXY")
35 .ok()
36 .or_else(|| std::env::var("HTTP_PROXY").ok()),
37 _ => {
38 if std::env::var("HTTP_PROXY").is_ok() || std::env::var("HTTPS_PROXY").is_ok() {
39 tracing::warn!(
40 "Ignoring HTTP proxy environment variables for non-HTTP client connection"
41 );
42 }
43 None
44 }
45 }
46 .map(|u| u.parse::<Url>().map_err(|e| anyhow!(e)))
47 .transpose(),
48 }
49}
50
51/// Create a Tendermint HTTP client.
52pub fn http_client(url: Url, proxy_url: Option<Url>) -> anyhow::Result<HttpClient> {

Callers 1

http_clientFunction · 0.85

Calls 1

okMethod · 0.80

Tested by

no test coverage detected