pub struct HttpClientBuilder { /* private fields */ }Expand description
Fluent builder for constructing a reusable HttpClient.
Implementations§
Source§impl HttpClientBuilder
Inherent implementation of HttpClientBuilder.
impl HttpClientBuilder
Inherent implementation of HttpClientBuilder.
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new HttpClientBuilder with keep-alive enabled by default.
§Returns
Self- Fresh client builder.
Sourcepub fn base_url<T>(self, url: T) -> Self
pub fn base_url<T>(self, url: T) -> Self
Configures a base URL prepended to relative paths passed to HttpClient request methods.
§Arguments
T- Base URL such as"https://api.example.com"or"http://127.0.0.1:8080/v1".
§Returns
Self- Updated client builder.
Sourcepub fn default_header<K, V>(self, key: K, value: V) -> Self
pub fn default_header<K, V>(self, key: K, value: V) -> Self
Sourcepub fn bearer_auth<T>(self, token: T) -> Self
pub fn bearer_auth<T>(self, token: T) -> Self
Sourcepub fn basic_auth<U, P>(self, username: U, password: P) -> Self
pub fn basic_auth<U, P>(self, username: U, password: P) -> Self
Sourcepub fn connect_timeout(self, ms: u64) -> Self
pub fn connect_timeout(self, ms: u64) -> Self
Sourcepub fn keep_alive(self, enabled: bool) -> Self
pub fn keep_alive(self, enabled: bool) -> Self
Sourcepub fn http1_1_only(self) -> Self
pub fn http1_1_only(self) -> Self
Sourcepub fn http2_only(self) -> Self
pub fn http2_only(self) -> Self
Sourcepub fn no_redirect(self) -> Self
pub fn no_redirect(self) -> Self
Sourcepub fn root_cert_pem(self, pem_bytes: &[u8]) -> Result<Self, RequestError>
pub fn root_cert_pem(self, pem_bytes: &[u8]) -> Result<Self, RequestError>
Sourcepub fn build(self) -> HttpClient
pub fn build(self) -> HttpClient
Finalizes the builder into a reusable, cheaply cloneable HttpClient.
§Returns
HttpClient- Constructed client instance.
Trait Implementations§
Source§impl Clone for HttpClientBuilder
impl Clone for HttpClientBuilder
Source§impl Debug for HttpClientBuilder
impl Debug for HttpClientBuilder
Source§impl Default for HttpClientBuilder
Default construction for HttpClientBuilder.
impl Default for HttpClientBuilder
Default construction for HttpClientBuilder.
Source§fn default() -> Self
fn default() -> Self
Creates an HttpClientBuilder with persistent keep-alive pooling enabled by default.
§Returns
Self- Default client builder withkeep_alive = true.
Auto Trait Implementations§
impl Forget for HttpClientBuilder
impl Freeze for HttpClientBuilderwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<(String, String)>: Freeze,
PhantomData<TrustAnchor<'static>>: Freeze,
impl Move for HttpClientBuilder
impl RefUnwindSafe for HttpClientBuilder
impl Send for HttpClientBuilder
impl Sync for HttpClientBuilder
impl Unpin for HttpClientBuilder
impl UnsafeUnpin for HttpClientBuilderwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<(String, String)>: UnsafeUnpin,
PhantomData<TrustAnchor<'static>>: UnsafeUnpin,
impl UnwindSafe for HttpClientBuilder
Blanket Implementations§
impl<T> AnySend for T
impl<T> AnySendClone for T
impl<T> AnySendSync for T
impl<T> AnySendSyncClone for T
impl<T> AnySync for T
impl<T> AnySyncClone for T
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