pub struct Builder { /* private fields */ }
Expand description

A builder to configure a new Client.

Example

use hyper::Client;

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

Implementations

Enable or disable keep-alive mechanics.

Default is enabled.

Set an optional timeout for idle sockets being kept-alive.

Pass None to disable timeout.

Default is 90 seconds.

Set whether HTTP/1 connections should try to use vectored writes, or always flatten into a single buffer.

Note that setting this to false may mean more copies of body data, but may also improve performance when an IO transport doesn’t support vectored writes well, such as most TLS implementations.

Default is true.

Sets the exact size of the read buffer to always use.

Note that setting this option unsets the http1_max_buf_size option.

Default is an adaptive read buffer.

Set the maximum buffer size for the connection.

Default is ~400kb.

Note that setting this option unsets the http1_read_exact_buf_size option.

Panics

The minimum value allowed is 8192. This method panics if the passed max is less than the minimum.

Set whether HTTP/1 connections will write header names as title case at the socket level.

Note that this setting does not affect HTTP/2.

Default is false.

Set whether the connection must use HTTP/2.

The destination must either allow HTTP2 Prior Knowledge, or the Connect should be configured to do use ALPN to upgrade to h2 as part of the connection process. This will not make the Client utilize ALPN by itself.

Note that setting this to true prevents HTTP/1 from being allowed.

Default is false.

Sets the SETTINGS_INITIAL_WINDOW_SIZE option for HTTP2 stream-level flow control.

Default is 65,535

Sets the max connection-level flow control for HTTP2

Default is 65,535

Sets the maximum idle connection per host allowed in the pool.

Default is usize::MAX (no limit).

Set whether to retry requests that get disrupted before ever starting to write.

This means a request that is queued, and gets given an idle, reused connection, and then encounters an error immediately as the idle connection was found to be unusable.

When this is set to false, the related ResponseFuture would instead resolve to an Error::Cancel.

Default is true.

Set whether to automatically add the Host header to requests.

If true, and a request does not include a Host header, one will be added automatically, derived from the authority of the Uri.

Default is true.

Provide an executor to execute background Connection tasks.

Builder a client with this configuration and the default HttpConnector.

Combine the configuration of this builder with a connector to create a Client.

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.