Module hyper::client[][src]

This is supported on crate feature client only.
Expand description

HTTP Client

There are two levels of APIs provided for construct HTTP clients:

  • The higher-level Client type.
  • The lower-level conn module.


The Client is the main way to send HTTP requests to a server. The default Client provides these things on top of the lower-level API:

  • A default connector, able to resolve hostnames and connect to destinations over plain-text TCP.
  • A pool of existing connections, allowing better performance when making multiple requests to the same hostname.
  • Automatic setting of the Host header, based on the request Uri.
  • Automatic request retries when a pooled connection is closed by the server before any bytes have been written.

Many of these features can configured, by making use of Client::builder.


For a small example program simply fetching a URL, take a look at the full client example.

use hyper::{body::HttpBody as _, Client, Uri};

let client = Client::new();

// Make a GET /ip to ''
let res = client.get(Uri::from_static("")).await?;

// And then, if the request gets a response...
println!("status: {}", res.status());

// Concatenate the body stream into a single buffer...
let buf = hyper::body::to_bytes(res).await?;

println!("body: {:?}", buf);


connhttp1 or http2

Lower-level client connection API.


Connectors used by the Client.

servicehttp1 or http2

Utilities used to interact with the Tower ecosystem.


Builderhttp1 or http2

A builder to configure a new Client.

Clienthttp1 or http2

A Client to make outgoing HTTP requests.


A connector for the http scheme.


A Future that will resolve to an HTTP Response.