pub struct HttpClient { /* private fields */ }Expand description
HTTP client shared by HTTP-calling nodes. Register it in
graphrt_core::Services; when absent, nodes use a client with the default
(restrictive) EgressPolicy.
Every connection goes through the policy:
- literal-IP URLs and every redirect hop are validated before connecting;
- host names are resolved by a guarded resolver that refuses non-public addresses, and the connection is made to exactly the addresses it returned (so DNS rebinding cannot swap in a private address afterwards);
- environment proxy variables are ignored.
Implementations§
Source§impl HttpClient
impl HttpClient
Sourcepub fn new(policy: EgressPolicy) -> Result<Self, ClientError>
pub fn new(policy: EgressPolicy) -> Result<Self, ClientError>
Build a client enforcing policy.
Sourcepub fn trusted() -> Result<Self, ClientError>
pub fn trusted() -> Result<Self, ClientError>
Client with EgressPolicy::trusted, for operator-configured endpoints.
pub fn policy(&self) -> &EgressPolicy
Sourcepub fn client(&self, verify_tls: bool) -> &Client
pub fn client(&self, verify_tls: bool) -> &Client
Underlying client. verify_tls = false disables certificate verification.
Redirects are followed automatically (each hop re-validated). reqwest strips only
authorization, cookie and proxy-authorization on cross-host hops, so callers
sending other credential headers should use HttpClient::manual_redirect_client.
Sourcepub fn manual_redirect_client(&self, verify_tls: bool) -> &Client
pub fn manual_redirect_client(&self, verify_tls: bool) -> &Client
Client that never follows redirects: 3xx responses are returned to the caller.
Trait Implementations§
Source§impl Clone for HttpClient
impl Clone for HttpClient
Auto Trait Implementations§
impl !RefUnwindSafe for HttpClient
impl !UnwindSafe for HttpClient
impl Forget for HttpClient
impl Freeze for HttpClient
impl Move for HttpClient
impl Send for HttpClient
impl Sync for HttpClient
impl Unpin for HttpClient
impl UnsafeUnpin for HttpClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more