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

A ClientBuilder can be used to create a Client with custom configuration.

Implementations

Constructs a new ClientBuilder.

This is the same as Client::builder().

Returns a Client that uses this ClientBuilder configuration.

Errors

This method fails if TLS backend cannot be initialized, or the resolver cannot load the system configuration.

Set that all sockets have SO_NODELAY set to true.

Use native TLS backend.

Add a custom root certificate.

This can be used to connect to a server that has a self-signed certificate for example.

Sets the identity to be used for client certificate authentication.

Controls the use of hostname verification.

Defaults to false.

Warning

You should think very carefully before you use this method. If hostname verification is not used, any valid certificate for any site will be trusted for use from any other. This introduces a significant vulnerability to man-in-the-middle attacks.

Controls the use of certificate validation.

Defaults to false.

Warning

You should think very carefully before using this method. If invalid certificates are trusted, any certificate for any site will be trusted for use. This includes expired certificates. This introduces significant vulnerabilities, and should only be used as a last resort.

Sets the default headers for every request.

Enable auto gzip decompression by checking the ContentEncoding response header.

If auto gzip decompresson is turned on:

  • When sending a request and if the request’s headers do not already contain an Accept-Encoding and Range values, the Accept-Encoding header is set to gzip. The body is not automatically inflated.
  • When receiving a response, if it’s headers contain a Content-Encoding value that equals to gzip, both values Content-Encoding and Content-Length are removed from the headers’ set. The body is automatically deinflated.

Default is enabled.

Add a Proxy to the list of proxies the Client will use.

Clear all Proxies, so Client will use no proxy anymore.

Add system proxy setting to the list of proxies

Set a RedirectPolicy for this client.

Default will follow redirects up to a maximum of 10.

Enable or disable automatic setting of the Referer header.

Default is true.

Enables a request timeout.

The timeout is applied from the when the request starts connecting until the response body has finished.

Default is no timeout.

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

Default is usize::MAX (no limit).

Only use HTTP/2.

Enable case sensitive headers.

Allow changing the Hyper runtime executor

Set a timeout for only the connect phase of a Client.

Default is None.

Note

This requires the futures be executed in a tokio runtime with a tokio timer enabled.

Bind to a local IP Address

Enable a persistent cookie store for the client.

Cookies received in responses will be preserved and included in additional requests.

By default, no cookie store is used.

Trait Implementations

Formats the value using the given formatter. 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 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.