Struct reqwest::async::ClientBuilder [−][src]
pub struct ClientBuilder { /* fields omitted */ }
A ClientBuilder
can be used to create a Client
with custom configuration:
Methods
impl ClientBuilder
[src]
impl ClientBuilder
pub fn new() -> ClientBuilder
[src]
pub fn new() -> ClientBuilder
Constructs a new ClientBuilder
pub fn build(self) -> Result<Client>
[src]
pub fn build(self) -> Result<Client>
Returns a Client
that uses this ClientBuilder
configuration.
Errors
This method fails if native TLS backend cannot be initialized.
pub fn add_root_certificate(self, cert: Certificate) -> ClientBuilder
[src]
pub fn add_root_certificate(self, cert: Certificate) -> ClientBuilder
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]
pub fn identity(self, identity: Identity) -> ClientBuilder
Sets the identity to be used for client certificate authentication.
pub fn danger_accept_invalid_hostnames(
self,
accept_invalid_hostname: bool
) -> ClientBuilder
[src]
pub fn danger_accept_invalid_hostnames(
self,
accept_invalid_hostname: bool
) -> ClientBuilder
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.
pub fn danger_accept_invalid_certs(
self,
accept_invalid_certs: bool
) -> ClientBuilder
[src]
pub fn danger_accept_invalid_certs(
self,
accept_invalid_certs: bool
) -> ClientBuilder
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.
pub fn default_headers(self, headers: HeaderMap) -> ClientBuilder
[src]
pub fn default_headers(self, headers: HeaderMap) -> ClientBuilder
Sets the default headers for every request.
pub fn gzip(self, enable: bool) -> ClientBuilder
[src]
pub fn gzip(self, enable: bool) -> ClientBuilder
Enable auto gzip decompression by checking the ContentEncoding response header.
Default is enabled.
pub fn proxy(self, proxy: Proxy) -> ClientBuilder
[src]
pub fn proxy(self, proxy: Proxy) -> ClientBuilder
Add a Proxy
to the list of proxies the Client
will use.
pub fn redirect(self, policy: RedirectPolicy) -> ClientBuilder
[src]
pub fn redirect(self, policy: RedirectPolicy) -> ClientBuilder
Set a RedirectPolicy
for this client.
Default will follow redirects up to a maximum of 10.
pub fn referer(self, enable: bool) -> ClientBuilder
[src]
pub fn referer(self, enable: bool) -> ClientBuilder
Enable or disable automatic setting of the Referer
header.
Default is true
.
pub fn timeout(self, timeout: Duration) -> ClientBuilder
[src]
pub fn timeout(self, timeout: Duration) -> ClientBuilder
Set a timeout for both the read and write operations of a client.
pub fn dns_threads(self, threads: usize) -> ClientBuilder
[src]
pub fn dns_threads(self, threads: usize) -> ClientBuilder
Set number of DNS threads.
Trait Implementations
impl Debug for ClientBuilder
[src]
impl Debug for ClientBuilder
Auto Trait Implementations
impl Send for ClientBuilder
impl Send for ClientBuilder
impl Sync for ClientBuilder
impl Sync for ClientBuilder