pub struct ClientBuilder { /* private fields */ }Expand description
An HTTP Client builder
This type can be used to construct an instance of Client through a
builder-like pattern.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
pub fn new() -> Self
Sourcepub fn connector<T>(self, connector: T) -> Selfwhere
T: Service<Request = Connect, Error = ConnectError> + 'static,
T::Response: Connection,
<T::Response as Connection>::Future: 'static,
T::Future: 'static,
pub fn connector<T>(self, connector: T) -> Selfwhere
T: Service<Request = Connect, Error = ConnectError> + 'static,
T::Response: Connection,
<T::Response as Connection>::Future: 'static,
T::Future: 'static,
Use custom connector service.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Set request timeout
Request timeout is the total time before a response must be received. Default value is 5 seconds.
Sourcepub fn disable_timeout(self) -> Self
pub fn disable_timeout(self) -> Self
Disable request timeout.
Sourcepub fn disable_redirects(self) -> Self
pub fn disable_redirects(self) -> Self
Do not follow redirects.
Redirects are allowed by default.
Sourcepub fn max_redirects(self, num: usize) -> Self
pub fn max_redirects(self, num: usize) -> Self
Set max number of redirects.
Max redirects is set to 10 by default.
Sourcepub fn no_default_headers(self) -> Self
pub fn no_default_headers(self) -> Self
Do not add default request headers.
By default Date and User-Agent headers are set.
Sourcepub fn header<K, V>(self, key: K, value: V) -> Selfwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Debug + Into<HttpError>,
V: IntoHeaderValue,
V::Error: Debug,
pub fn header<K, V>(self, key: K, value: V) -> Selfwhere
HeaderName: TryFrom<K>,
<HeaderName as TryFrom<K>>::Error: Debug + Into<HttpError>,
V: IntoHeaderValue,
V::Error: Debug,
Add default header. Headers added by this method get added to every request.
Sourcepub fn basic_auth<U>(self, username: U, password: Option<&str>) -> Selfwhere
U: Display,
pub fn basic_auth<U>(self, username: U, password: Option<&str>) -> Selfwhere
U: Display,
Set client wide HTTP basic authorization header
Sourcepub fn bearer_auth<T>(self, token: T) -> Selfwhere
T: Display,
pub fn bearer_auth<T>(self, token: T) -> Selfwhere
T: Display,
Set client wide HTTP bearer authentication header
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ClientBuilder
impl !RefUnwindSafe for ClientBuilder
impl !Send for ClientBuilder
impl !Sync for ClientBuilder
impl !UnwindSafe for ClientBuilder
impl Unpin for ClientBuilder
impl UnsafeUnpin for ClientBuilder
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more