pub struct HttpClientBuilder { /* private fields */ }Expand description
Builder for HttpClient.
This provides a reqwest-style fluent API for configuring the high-level HTTP client and its underlying connection pool defaults.
Implementations§
Source§impl HttpClientBuilder
impl HttpClientBuilder
Sourcepub fn pool_config(self, pool_config: PoolConfig) -> Self
pub fn pool_config(self, pool_config: PoolConfig) -> Self
Replaces the full pool configuration.
Sourcepub fn max_connections_per_host(self, max: usize) -> Self
pub fn max_connections_per_host(self, max: usize) -> Self
Sets max pooled connections per host.
Sourcepub fn max_total_connections(self, max: usize) -> Self
pub fn max_total_connections(self, max: usize) -> Self
Sets max pooled connections across all hosts.
Sourcepub fn idle_timeout(self, timeout: Duration) -> Self
pub fn idle_timeout(self, timeout: Duration) -> Self
Sets idle timeout for pooled connections.
Sourcepub fn cleanup_interval(self, interval: Duration) -> Self
pub fn cleanup_interval(self, interval: Duration) -> Self
Sets cleanup interval for idle pooled connections.
Sourcepub fn request_timeout(self, timeout: Duration) -> Self
pub fn request_timeout(self, timeout: Duration) -> Self
Sets the default total request timeout (br-asupersync-server-stack-hardening-eeexl1.1.3).
Meet-composed with the remaining ambient budget and any per-call
override; the tightest bound wins (see
HttpClientConfig::request_timeout).
Sourcepub fn redirect_policy(self, policy: RedirectPolicy) -> Self
pub fn redirect_policy(self, policy: RedirectPolicy) -> Self
Sets redirect behavior.
Sourcepub fn max_redirects(self, max: u32) -> Self
pub fn max_redirects(self, max: u32) -> Self
Follows up to max redirects.
Sourcepub fn same_origin_redirects(self, max: u32) -> Self
pub fn same_origin_redirects(self, max: u32) -> Self
Follows redirects only when the target has the same scheme, host, and port as the original request.
Sourcepub fn no_redirects(self) -> Self
pub fn no_redirects(self) -> Self
Disables automatic redirect following.
Sourcepub fn retry_policy(self, policy: RetryPolicy) -> Self
pub fn retry_policy(self, policy: RetryPolicy) -> Self
Sets automatic retry behavior.
Sourcepub fn retry_safe_methods_on_stale_reuse(self) -> Self
pub fn retry_safe_methods_on_stale_reuse(self) -> Self
Retries safe methods once when a reused pooled connection is stale.
Sourcepub fn retry_idempotent_statuses(self, max_retries: u32) -> Self
pub fn retry_idempotent_statuses(self, max_retries: u32) -> Self
Retries idempotent methods on retryable response status codes.
Valid Retry-After delta-seconds response headers are honored before
retrying. Use Self::no_retries when no automatic retry behavior is
desired.
Sourcepub fn no_retries(self) -> Self
pub fn no_retries(self) -> Self
Disables all automatic retries.
Sourcepub fn user_agent(self, user_agent: impl Into<String>) -> Self
pub fn user_agent(self, user_agent: impl Into<String>) -> Self
Sets default User-Agent.
Sourcepub fn no_user_agent(self) -> Self
pub fn no_user_agent(self) -> Self
Removes default User-Agent.
Sourcepub fn default_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn default_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a default header to every request unless that request supplies the same header name.
Sourcepub fn default_headers<I, N, V>(self, headers: I) -> Self
pub fn default_headers<I, N, V>(self, headers: I) -> Self
Adds multiple default headers.
Enables/disables automatic cookie persistence and attachment.
Disables automatic cookie persistence and attachment.
Sourcepub fn max_body_size(self, size: usize) -> Self
pub fn max_body_size(self, size: usize) -> Self
Sourcepub fn proxy(self, proxy_url: impl Into<String>) -> Self
pub fn proxy(self, proxy_url: impl Into<String>) -> Self
Routes requests through a proxy endpoint.
Supported URL schemes: http://, https://, and socks5://.
Sourcepub fn with_time_getter(self, time_getter: fn() -> Time) -> Self
pub fn with_time_getter(self, time_getter: fn() -> Time) -> Self
Sets a custom time source for deterministic pool timestamps.
Sourcepub fn build(self) -> HttpClient
pub fn build(self) -> HttpClient
Builds the HttpClient.
Trait Implementations§
Source§impl Clone for HttpClientBuilder
impl Clone for HttpClientBuilder
Source§fn clone(&self) -> HttpClientBuilder
fn clone(&self) -> HttpClientBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more