pub struct ClientBuilder { /* private fields */ }Expand description
Configures a Client.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn timeout_idle(self, limit: Duration) -> Self
pub fn timeout_idle(self, limit: Duration) -> Self
How long an exchange may sit without progress, for requests that set no
Request::timeout. Default 30 s.
Sourcepub fn timeout_total(self, limit: Duration) -> Self
pub fn timeout_total(self, limit: Duration) -> Self
How long a whole request may take, redirects, challenges and body included. Default
none. A request’s own Request::timeout_total wins.
Sourcepub fn redirects(self, redirects: Redirects) -> Self
pub fn redirects(self, redirects: Redirects) -> Self
Whether to follow redirects. Default Redirects::Follow(10).
Sourcepub fn on_redirect(
self,
handler: impl Fn(&Hop, RedirectReply) + Send + Sync + 'static,
) -> Self
pub fn on_redirect( self, handler: impl Fn(&Hop, RedirectReply) + Send + Sync + 'static, ) -> Self
Ask before following each redirect. Needs Capabilities::manual_redirects; where the
platform follows redirects itself, requests from this client fail with
HttpError::Unsupported.
Sourcepub fn on_challenge(
self,
handler: impl Fn(&Challenge, ChallengeReply) + Send + Sync + 'static,
) -> Self
pub fn on_challenge( self, handler: impl Fn(&Challenge, ChallengeReply) + Send + Sync + 'static, ) -> Self
Answer authentication challenges. Without a handler a 401 or 407 is delivered as the response.
Sourcepub fn trust(self, trust: Trust) -> Self
pub fn trust(self, trust: Trust) -> Self
Public-key pins, checked on top of the platform’s evaluation.
Sourcepub fn on_server_trust(
self,
handler: impl Fn(&ServerTrust, TrustReply) + Send + Sync + 'static,
) -> Self
pub fn on_server_trust( self, handler: impl Fn(&ServerTrust, TrustReply) + Send + Sync + 'static, ) -> Self
Decide on servers the platform does not trust, or confirm the ones it does. Needs
Capabilities::server_trust.
Sourcepub fn identity(self, identity: Identity) -> Self
pub fn identity(self, identity: Identity) -> Self
Present this identity when a server asks for a client certificate. Needs
Capabilities::client_identity.
Where to keep cookies. Default Cookies::default.
Sourcepub fn cache(self, cache: Cache) -> Self
pub fn cache(self, cache: Cache) -> Self
Whether to keep an HTTP cache. Default Cache::platform.
Sourcepub fn header(self, name: &str, value: &str) -> Self
pub fn header(self, name: &str, value: &str) -> Self
A header sent with every request that does not set it itself.
Sourcepub fn user_agent(self, agent: &str) -> Self
pub fn user_agent(self, agent: &str) -> Self
The User-Agent sent with every request.
Sourcepub fn max_per_host(self, limit: u32) -> Self
pub fn max_per_host(self, limit: u32) -> Self
At most this many connections to one host, where the platform lets an app choose.
Sourcepub fn wait_for_connectivity(self, wait: bool) -> Self
pub fn wait_for_connectivity(self, wait: bool) -> Self
Wait for a usable network instead of failing at once, where the platform can
(Capabilities::wait_for_connectivity).
Sourcepub fn question_timeout(self, limit: Duration) -> Self
pub fn question_timeout(self, limit: Duration) -> Self
How long a handler may hold a question before its default answer is taken. Default two minutes.
Sourcepub fn session(self, session: Session) -> Self
pub fn session(self, session: Session) -> Self
Route through an isolated session. By default clients follow Session::global().
An explicit transport overrides provider/interception selection for this client.