pub struct Client { /* private fields */ }Expand description
Async HTTP client.
The client manages connection pooling and shared configuration. Create one
with Client::new or Client::builder.
Implementations§
Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Create a ClientBuilder for configuring a client.
Sourcepub fn get(&self, url: &str) -> Result<RequestBuilder>
pub fn get(&self, url: &str) -> Result<RequestBuilder>
Create a GET request builder for the given URL.
§Errors
Returns Error::InvalidUrl if url cannot be parsed.
Sourcepub fn post(&self, url: &str) -> Result<RequestBuilder>
pub fn post(&self, url: &str) -> Result<RequestBuilder>
Create a POST request builder for the given URL.
§Errors
Returns Error::InvalidUrl if url cannot be parsed.
Sourcepub fn put(&self, url: &str) -> Result<RequestBuilder>
pub fn put(&self, url: &str) -> Result<RequestBuilder>
Create a PUT request builder for the given URL.
§Errors
Returns Error::InvalidUrl if url cannot be parsed.
Sourcepub fn patch(&self, url: &str) -> Result<RequestBuilder>
pub fn patch(&self, url: &str) -> Result<RequestBuilder>
Create a PATCH request builder for the given URL.
§Errors
Returns Error::InvalidUrl if url cannot be parsed.
Sourcepub fn delete(&self, url: &str) -> Result<RequestBuilder>
pub fn delete(&self, url: &str) -> Result<RequestBuilder>
Create a DELETE request builder for the given URL.
§Errors
Returns Error::InvalidUrl if url cannot be parsed.
Sourcepub fn head(&self, url: &str) -> Result<RequestBuilder>
pub fn head(&self, url: &str) -> Result<RequestBuilder>
Create a HEAD request builder for the given URL.
§Errors
Returns Error::InvalidUrl if url cannot be parsed.
Sourcepub fn options(&self, url: &str) -> Result<RequestBuilder>
pub fn options(&self, url: &str) -> Result<RequestBuilder>
Create an OPTIONS request builder for the given URL.
§Errors
Returns Error::InvalidUrl if url cannot be parsed.
Sourcepub fn request(&self, method: Method, url: &str) -> Result<RequestBuilder>
pub fn request(&self, method: Method, url: &str) -> Result<RequestBuilder>
Create a request builder for the given method and URL.
§Errors
Returns Error::InvalidUrl if url cannot be parsed.
Sourcepub fn pool_metrics(&self) -> &PoolMetrics
pub fn pool_metrics(&self) -> &PoolMetrics
Returns a reference to the connection pool metrics.
These count logical request-permit waits/cancellations. For
connector/protocol observations see Self::transport_metrics.
Sourcepub fn transport_metrics(&self) -> &TransportMetrics
pub fn transport_metrics(&self) -> &TransportMetrics
Returns a reference to the transport observability counters.
Counts connector events (DNS/connect/TLS attempts) and protocol connections (H3 sessions, 101 upgrades) where observable. Hyper socket-reuse counts are intentionally absent.
Sourcepub async fn send_detailed(
&self,
request: Request,
) -> Result<Response, RequestFailure>
pub async fn send_detailed( &self, request: Request, ) -> Result<Response, RequestFailure>
Send a request and return optional structured native failure detail.
The ordinary Error remains unchanged and can be recovered with
RequestFailure::into_error.
Network classifications are reported only when the selected route
exposes typed evidence; callers must not treat an absent subtype as a
positive diagnosis.
§Errors
Returns the original request error wrapped in crate::RequestFailure.
Sourcepub async fn execute_http_body<B>(
&self,
request: Request<B>,
options: NativeRequestOptions,
) -> Result<Response<NativeResponseBody>>
pub async fn execute_http_body<B>( &self, request: Request<B>, options: NativeRequestOptions, ) -> Result<Response<NativeResponseBody>>
Execute a native http_body::Body using eggfetch’s HTTP/TLS
transport engine.
This is the lower-level native embedding API. Request DATA and
trailer frames are passed through without flattening. The response is
an ordinary http::Response whose opaque crate::NativeResponseBody
preserves DATA and trailer frames and holds the logical pool lease
until the body reaches EOF, errors, or is dropped.
Native execution does not implicitly apply redirects, logical retries, cookies, authentication, response decompression, or decoded body limits. The request body is one-shot. Built-in proxy, HTTP/3, and protocol-upgrade routes are rejected because their current adapters do not expose the frame-preserving contract.
§Errors
Returns an error for an invalid logical URI, unsupported route, pool or transport failure, or a timeout.
Sourcepub async fn execute_http_body_default<B>(
&self,
request: Request<B>,
) -> Result<Response<NativeResponseBody>>
pub async fn execute_http_body_default<B>( &self, request: Request<B>, ) -> Result<Response<NativeResponseBody>>
Execute a native body request with default native transport options.
§Errors
Returns the same URI, pool, transport, and timeout errors as
Self::execute_http_body.
Source§impl Client
impl Client
Sourcepub fn native_service(&self) -> NativeHttpService
pub fn native_service(&self) -> NativeHttpService
Create a Tower service for the native frame-preserving HTTP path.
The returned service is configured with NativeRequestOptions::default.
Use NativeHttpService::with_options to configure service-instance
defaults, or call Client::execute_http_body directly for options
that vary by request.