Skip to main content

HttpClientBuilder

Struct HttpClientBuilder 

Source
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

Source

pub fn new() -> Self

Creates a builder with default configuration.

Source

pub fn pool_config(self, pool_config: PoolConfig) -> Self

Replaces the full pool configuration.

Source

pub fn max_connections_per_host(self, max: usize) -> Self

Sets max pooled connections per host.

Source

pub fn max_total_connections(self, max: usize) -> Self

Sets max pooled connections across all hosts.

Source

pub fn idle_timeout(self, timeout: Duration) -> Self

Sets idle timeout for pooled connections.

Source

pub fn cleanup_interval(self, interval: Duration) -> Self

Sets cleanup interval for idle pooled connections.

Source

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).

Source

pub fn redirect_policy(self, policy: RedirectPolicy) -> Self

Sets redirect behavior.

Source

pub fn max_redirects(self, max: u32) -> Self

Follows up to max redirects.

Source

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.

Source

pub fn no_redirects(self) -> Self

Disables automatic redirect following.

Source

pub fn retry_policy(self, policy: RetryPolicy) -> Self

Sets automatic retry behavior.

Source

pub fn retry_safe_methods_on_stale_reuse(self) -> Self

Retries safe methods once when a reused pooled connection is stale.

Source

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.

Source

pub fn no_retries(self) -> Self

Disables all automatic retries.

Source

pub fn user_agent(self, user_agent: impl Into<String>) -> Self

Sets default User-Agent.

Source

pub fn no_user_agent(self) -> Self

Removes default User-Agent.

Source

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.

Source

pub fn default_headers<I, N, V>(self, headers: I) -> Self
where I: IntoIterator<Item = (N, V)>, N: Into<String>, V: Into<String>,

Adds multiple default headers.

Source

pub fn cookie_store(self, enabled: bool) -> Self

Enables/disables automatic cookie persistence and attachment.

Disables automatic cookie persistence and attachment.

Source

pub fn max_body_size(self, size: usize) -> Self

Sets the maximum response body size in bytes.

By default, the HTTP/1.1 codec limits responses to 16 MiB. Use this to raise the limit when downloading large files.

§Example
let client = HttpClient::builder()
    .max_body_size(500 * 1024 * 1024) // 500 MB
    .build();
Source

pub fn proxy(self, proxy_url: impl Into<String>) -> Self

Routes requests through a proxy endpoint.

Supported URL schemes: http://, https://, and socks5://.

Source

pub fn no_proxy(self) -> Self

Disables proxy routing.

Source

pub fn with_time_getter(self, time_getter: fn() -> Time) -> Self

Sets a custom time source for deterministic pool timestamps.

Source

pub fn build(self) -> HttpClient

Builds the HttpClient.

Trait Implementations§

Source§

impl Clone for HttpClientBuilder

Source§

fn clone(&self) -> HttpClientBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HttpClientBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HttpClientBuilder

Source§

fn default() -> HttpClientBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V