pub struct Client<R: Runtime> { /* private fields */ }Expand description
HTTP client with connection pooling, TLS, and automatic redirect handling.
Implementations§
Source§impl<R: Runtime> Client<R>
impl<R: Runtime> Client<R>
Sourcepub fn builder() -> ClientBuilder<R>
pub fn builder() -> ClientBuilder<R>
Create a new ClientBuilder with default settings.
Sourcepub fn with_rustls() -> Self
pub fn with_rustls() -> Self
Create a client with rustls TLS using WebPKI root certificates.
Sourcepub fn with_native_roots() -> Self
pub fn with_native_roots() -> Self
Create a client with rustls TLS using the system’s native root certificates.
Sourcepub fn with_http3() -> Self
pub fn with_http3() -> Self
Create a client configured for HTTP/3 with rustls.
Sourcepub fn with_alt_svc_h3() -> Self
pub fn with_alt_svc_h3() -> Self
Create a client that upgrades to HTTP/3 via Alt-Svc discovery.
Sourcepub fn get(&self, uri: &str) -> Result<RequestBuilder<'_, R>, Error>
pub fn get(&self, uri: &str) -> Result<RequestBuilder<'_, R>, Error>
Start a GET request to the given URL.
Sourcepub fn head(&self, uri: &str) -> Result<RequestBuilder<'_, R>, Error>
pub fn head(&self, uri: &str) -> Result<RequestBuilder<'_, R>, Error>
Start a HEAD request to the given URL.
Sourcepub fn post(&self, uri: &str) -> Result<RequestBuilder<'_, R>, Error>
pub fn post(&self, uri: &str) -> Result<RequestBuilder<'_, R>, Error>
Start a POST request to the given URL.
Sourcepub fn put(&self, uri: &str) -> Result<RequestBuilder<'_, R>, Error>
pub fn put(&self, uri: &str) -> Result<RequestBuilder<'_, R>, Error>
Start a PUT request to the given URL.
Sourcepub fn patch(&self, uri: &str) -> Result<RequestBuilder<'_, R>, Error>
pub fn patch(&self, uri: &str) -> Result<RequestBuilder<'_, R>, Error>
Start a PATCH request to the given URL.
Sourcepub fn delete(&self, uri: &str) -> Result<RequestBuilder<'_, R>, Error>
pub fn delete(&self, uri: &str) -> Result<RequestBuilder<'_, R>, Error>
Start a DELETE request to the given URL.
Sourcepub fn request(
&self,
method: Method,
uri: &str,
) -> Result<RequestBuilder<'_, R>, Error>
pub fn request( &self, method: Method, uri: &str, ) -> Result<RequestBuilder<'_, R>, Error>
Start a request with the given method and URL.
Sourcepub fn chunk_download(&self, url: &str) -> ChunkDownload<R>
pub fn chunk_download(&self, url: &str) -> ChunkDownload<R>
Start a parallel chunk download for the given URL.
Sourcepub fn forward<B>(&self, request: Request<B>) -> ForwardBuilder<'_, R, B>
pub fn forward<B>(&self, request: Request<B>) -> ForwardBuilder<'_, R, B>
Forward an incoming HTTP request to an upstream server.
This is the entry point for proxy/gateway use cases. The forwarded request bypasses all client middleware (redirects, cookies, cache, decompression) and streams the body directly to the upstream.
Sourcepub fn bandwidth_limiter(&self) -> Option<&BandwidthLimiter>
pub fn bandwidth_limiter(&self) -> Option<&BandwidthLimiter>
Returns the bandwidth limiter if one was configured via ClientBuilder::max_download_speed.
Trait Implementations§
Auto Trait Implementations§
impl<R> !Freeze for Client<R>
impl<R> !RefUnwindSafe for Client<R>
impl<R> Send for Client<R>
impl<R> Sync for Client<R>
impl<R> Unpin for Client<R>where
R: Unpin,
impl<R> UnsafeUnpin for Client<R>
impl<R> !UnwindSafe for Client<R>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 more