[][src]Struct reqwest::async::ClientBuilder

pub struct ClientBuilder { /* fields omitted */ }

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


impl ClientBuilder[src]

pub fn new() -> ClientBuilder[src]

Constructs a new ClientBuilder.

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

pub fn build(self) -> Result<Client>[src]

Returns a Client that uses this ClientBuilder configuration.


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

pub fn tcp_nodelay(self) -> ClientBuilder[src]

Set that all sockets have SO_NODELAY set to true.

pub fn use_default_tls(self) -> ClientBuilder[src]

Use native TLS backend.

pub fn use_rustls_tls(self) -> ClientBuilder[src]

Use rustls TLS backend.

pub fn add_root_certificate(self, cert: Certificate) -> ClientBuilder[src]

Add a custom root certificate.

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

pub fn identity(self, identity: Identity) -> ClientBuilder[src]

Sets the identity to be used for client certificate authentication.

pub fn danger_accept_invalid_hostnames(
    accept_invalid_hostname: bool
) -> ClientBuilder

Controls the use of hostname verification.

Defaults to false.


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.

pub fn danger_accept_invalid_certs(
    accept_invalid_certs: bool
) -> ClientBuilder

Controls the use of certificate validation.

Defaults to false.


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.

pub fn default_headers(self, headers: HeaderMap) -> ClientBuilder[src]

Sets the default headers for every request.

pub fn gzip(self, enable: bool) -> ClientBuilder[src]

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.

pub fn proxy(self, proxy: Proxy) -> ClientBuilder[src]

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

pub fn no_proxy(self) -> ClientBuilder[src]

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

pub fn use_sys_proxy(self) -> ClientBuilder[src]

Add system proxy setting to the list of proxies

pub fn redirect(self, policy: RedirectPolicy) -> ClientBuilder[src]

Set a RedirectPolicy for this client.

Default will follow redirects up to a maximum of 10.

pub fn referer(self, enable: bool) -> ClientBuilder[src]

Enable or disable automatic setting of the Referer header.

Default is true.

pub fn timeout(self, timeout: Duration) -> ClientBuilder[src]

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.

pub fn max_idle_per_host(self, max: usize) -> ClientBuilder[src]

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

Default is usize::MAX (no limit).

pub fn h2_prior_knowledge(self) -> ClientBuilder[src]

Only use HTTP/2.

pub fn http1_title_case_headers(self) -> ClientBuilder[src]

Enable case sensitive headers.

pub fn connect_timeout(self, timeout: Duration) -> ClientBuilder[src]

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

Default is None.


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

pub fn local_address<T>(self, addr: T) -> ClientBuilder where
    T: Into<Option<IpAddr>>, 

Bind to a local IP Address

pub fn cookie_store(self, enable: bool) -> ClientBuilder[src]

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

impl Debug for ClientBuilder[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> Any for T where
    T: 'static + ?Sized

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err

impl<T> Erased for T