#[non_exhaustive]pub struct HttpClientConfig {
pub base_url: Option<String>,
pub timeout: Duration,
pub connect_timeout: Duration,
pub user_agent: Option<String>,
pub default_headers: HashMap<String, String>,
pub auth: Option<Auth>,
pub follow_redirects: bool,
pub max_redirects: usize,
pub max_response_body_bytes: usize,
pub destination_policy: DestinationPolicy,
pub resilience_policy: Option<Policy>,
pub tls: Option<TlsConfig>,
}Expand description
Configuration for the HTTP client.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.base_url: Option<String>Base URL for requests (e.g., https://api.example.com/v1).
Paths are appended to this URL.
timeout: DurationRequest timeout. Defaults to 30 seconds.
connect_timeout: DurationConnection timeout. Defaults to 10 seconds.
user_agent: Option<String>User-Agent header value. If None, no User-Agent header is set.
default_headers: HashMap<String, String>Default headers applied to all requests.
auth: Option<Auth>Default authentication applied to all requests.
follow_redirects: boolFollow redirects. Defaults to true.
max_redirects: usizeMaximum number of redirects to follow. Defaults to 5.
max_response_body_bytes: usizeMaximum response body size accepted by HttpClient.
destination_policy: DestinationPolicyDestination policy for initial request URLs and redirect targets.
resilience_policy: Option<Policy>Optional resilience policy applied to transport execution.
tls: Option<TlsConfig>Explicit TLS certificate, trust, and verification configuration.
Implementations§
Source§impl HttpClientConfig
impl HttpClientConfig
Sourcepub fn with_base_url(self, url: impl Into<String>) -> Self
pub fn with_base_url(self, url: impl Into<String>) -> Self
Sets the base URL.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Sets the timeout.
Sourcepub fn with_connect_timeout(self, timeout: Duration) -> Self
pub fn with_connect_timeout(self, timeout: Duration) -> Self
Sets the connection timeout.
Sourcepub fn with_user_agent(self, ua: impl Into<String>) -> Self
pub fn with_user_agent(self, ua: impl Into<String>) -> Self
Sets the User-Agent header.
Sourcepub fn with_header(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a default header.
Sourcepub fn with_headers(self, headers: HashMap<String, String>) -> Self
pub fn with_headers(self, headers: HashMap<String, String>) -> Self
Sets default headers.
Sourcepub fn with_follow_redirects(self, follow: bool) -> Self
pub fn with_follow_redirects(self, follow: bool) -> Self
Sets whether to follow redirects.
Sourcepub fn with_max_redirects(self, max: usize) -> Self
pub fn with_max_redirects(self, max: usize) -> Self
Sets the maximum number of redirects to follow.
Sourcepub fn with_max_response_body_bytes(self, max: usize) -> Self
pub fn with_max_response_body_bytes(self, max: usize) -> Self
Sets the maximum accepted response body size.
Sourcepub fn with_destination_policy(self, policy: DestinationPolicy) -> Self
pub fn with_destination_policy(self, policy: DestinationPolicy) -> Self
Sets the destination validation policy.
Sourcepub fn with_resilience_policy(self, policy: Policy) -> Self
pub fn with_resilience_policy(self, policy: Policy) -> Self
Sets the transport resilience policy.
Trait Implementations§
Source§impl Clone for HttpClientConfig
impl Clone for HttpClientConfig
Source§fn clone(&self) -> HttpClientConfig
fn clone(&self) -> HttpClientConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more