pub struct ClientBuilder { /* private fields */ }Expand description
Builds a Client.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
A builder with the defaults: no client-level timeout, a
DEFAULT_MAX_RESPONSE_BYTES read limit, DEFAULT_MAX_REDIRECTS.
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Bound connection setup.
Sourcepub fn read_timeout(self, timeout: Duration) -> Self
pub fn read_timeout(self, timeout: Duration) -> Self
Bound each idle read, so a long streamed body is not cut while it keeps arriving.
Sourcepub fn user_agent(self, user_agent: &str) -> Self
pub fn user_agent(self, user_agent: &str) -> Self
Send user_agent on every request.
Sourcepub fn default_headers(self, headers: HeaderMap) -> Self
pub fn default_headers(self, headers: HeaderMap) -> Self
Send headers on every request.
Sourcepub fn proxy(self, url: &str) -> Self
pub fn proxy(self, url: &str) -> Self
Route every request through the proxy at url. A malformed URL fails
build.
Sourcepub fn max_redirects(self, n: usize) -> Self
pub fn max_redirects(self, n: usize) -> Self
Follow at most n redirects (0 returns the redirect response).
Sourcepub fn max_response_bytes(self, limit: Option<u64>) -> Self
pub fn max_response_bytes(self, limit: Option<u64>) -> Self
Refuse a buffered body above limit bytes; None lifts the limit.
Sourcepub fn reference_policy(self, policy: Arc<ReferencePolicy>) -> Self
pub fn reference_policy(self, policy: Arc<ReferencePolicy>) -> Self
Check the first request and every redirect hop send
follows against policy, instead of the one scoped over the task
(with_reference_policy).
Sourcepub fn sensitive_header(self, name: &str) -> Self
pub fn sensitive_header(self, name: &str) -> Self
Drop the header name on a redirect to another origin, like
Authorization. Name every header that carries a credential (an API
key, a session id). An invalid name fails build.
Sourcepub fn configure(self, f: impl FnOnce(ClientBuilder) -> ClientBuilder) -> Self
pub fn configure(self, f: impl FnOnce(ClientBuilder) -> ClientBuilder) -> Self
Set any other reqwest option: |b| b.gzip(true), an identity, root
certificates. Don’t set a redirect policy here — redirects are followed
by Client::send, which strips credentials on a cross-origin hop.
Sourcepub fn try_configure(
self,
f: impl FnOnce(ClientBuilder) -> Result<ClientBuilder, FaucetError>,
) -> Result<Self, FaucetError>
pub fn try_configure( self, f: impl FnOnce(ClientBuilder) -> Result<ClientBuilder, FaucetError>, ) -> Result<Self, FaucetError>
Like configure for a step that can fail.
Sourcepub fn build_reqwest(self) -> Result<Client, FaucetError>
pub fn build_reqwest(self) -> Result<Client, FaucetError>
Build a plain reqwest::Client with these settings, for a connector
whose public API already hands out a reqwest client. It follows
same-origin redirects only; prefer build, which also
follows cross-origin hops safely and bounds reads.
Sourcepub fn build(self) -> Result<Client, FaucetError>
pub fn build(self) -> Result<Client, FaucetError>
Build the client.
Trait Implementations§
Source§impl Debug for ClientBuilder
impl Debug for ClientBuilder
Auto Trait Implementations§
impl !RefUnwindSafe for ClientBuilder
impl !UnwindSafe for ClientBuilder
impl Freeze for ClientBuilder
impl Send for ClientBuilder
impl Sync 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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request