pub struct Client<C, B = Body> {
    config: Config,
    conn_builder: Builder,
    connector: C,
    pool: Pool<PoolClient<B>>,
}
Expand description

A Client to make outgoing HTTP requests.

Fields

config: Configconn_builder: Builderconnector: Cpool: Pool<PoolClient<B>>

Implementations

Create a new Client with the default config.

Note

The default connector does not handle TLS. Speaking to https destinations will require configuring a connector that implements TLS.

Create a builder to configure a new Client.

Example
use std::time::Duration;
use hyper::Client;

let client = Client::builder()
    .pool_idle_timeout(Duration::from_secs(30))
    .http2_only(true)
    .build_http();

Send a GET request to the supplied Uri.

Note

This requires that the HttpBody type have a Default implementation. It should return an “empty” version of itself, such that HttpBody::is_end_stream is true.

Example
use hyper::{Client, Uri};

let client = Client::new();

let future = client.get(Uri::from_static("http://httpbin.org/ip"));

Send a constructed Request using this Client.

Example
use hyper::{Body, Method, Client, Request};

let client = Client::new();

let req = Request::builder()
    .method(Method::POST)
    .uri("http://httpbin.org/post")
    .body(Body::from("Hallo!"))
    .expect("request builder");

let future = client.request(req);

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Responses given by the service.

Errors produced by the service.

The future response value.

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more

Process the request and return the response asynchronously. Read more

Responses given by the service.

Errors produced by the service.

The future response value.

Returns Poll::Ready(Ok(())) when the service is able to process requests. Read more

Process the request and return the response asynchronously. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more