pub struct Client<C, B = Body> { /* private fields */ }
Expand description

A Client to make outgoing HTTP requests.

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 hyper::Client;

let client = Client::builder()
    .keep_alive(true)
    .http2_only(true)
    .build_http();

Send a GET request to the supplied Uri.

Note

This requires that the Payload type have a Default implementation. It should return an “empty” version of itself, such that Payload::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, Client, Request};

let client = Client::new();

let req = Request::builder()
    .method("POST")
    .uri("http://httpin.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

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.

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.