Struct hyper::client::Client[][src]

pub struct Client<C, B = Body> { /* fields omitted */ }
This is supported on crate feature client and (crate features http1 or http2) only.
Expand description

A Client to make outgoing HTTP requests.

Client is cheap to clone and cloning is the recommended way to share a Client. The underlying connection pool will be reused.

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

Performs the conversion.

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

Performs the conversion.

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)

recently added

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.