pub struct HttpClientBuilder { /* private fields */ }
Expand description
A HttpClientBuilder
can be used to create a HttpClient
with custom configuration.
Implementations§
Source§impl HttpClientBuilder
impl HttpClientBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new HttpClientBuilder
.
This is the same as HttpClient::builder()
.
Sourcepub fn basic_auth<U, P>(self, username: U, password: Option<P>) -> Self
pub fn basic_auth<U, P>(self, username: U, password: Option<P>) -> Self
Enable basic authentication.
Sourcepub fn bearer_auth<T>(self, token: T) -> Selfwhere
T: Display,
pub fn bearer_auth<T>(self, token: T) -> Selfwhere
T: Display,
Enable bearer authentication.
Sourcepub fn header(self, name: HeaderName, value: HeaderValue) -> Self
pub fn header(self, name: HeaderName, value: HeaderValue) -> Self
Adds a Header
for every request.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Enables a request timeout.
The timeout is applied from when the request starts connecting until the response body has finished.
Default is no timeout.
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Set a timeout for only the connect phase of a Client
.
Default is None
.
Sourcepub fn build<U: Into<String>>(
self,
url: U,
) -> Result<HttpClient, HttpClientError>
pub fn build<U: Into<String>>( self, url: U, ) -> Result<HttpClient, HttpClientError>
Returns a HttpClient
that uses this HttpClientBuilder
configuration.
Trait Implementations§
Source§impl Debug for HttpClientBuilder
impl Debug for HttpClientBuilder
Auto Trait Implementations§
impl Freeze for HttpClientBuilder
impl RefUnwindSafe for HttpClientBuilder
impl Send for HttpClientBuilder
impl Sync for HttpClientBuilder
impl Unpin for HttpClientBuilder
impl UnwindSafe for HttpClientBuilder
Blanket Implementations§
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