[][src]Struct spirit_reqwest::ReqwestClient

#[non_exhaustive]pub struct ReqwestClient {
    pub user_agent: Option<String>,
    pub pool_idle_timeout: Option<Duration>,
    pub http2_initial_stream_window_size: Option<u32>,
    pub http2_initial_connection_window_size: Option<u32>,
    pub tcp_nodelay: bool,
    pub tls_extra_root_certs: Vec<PathBuf>,
    pub tls_identity: Option<PathBuf>,
    pub tls_identity_password: Option<Hidden<String>>,
    pub tls_accept_invalid_hostnames: bool,
    pub tls_accept_invalid_certs: bool,
    pub enable_gzip: bool,
    pub enable_brotli: bool,
    pub default_headers: HashMap<String, String>,
    pub timeout: Option<Duration>,
    pub connect_timeout: Option<Duration>,
    pub http_proxy: Option<Url>,
    pub https_proxy: Option<Url>,
    pub disable_proxy: bool,
    pub redirects: Option<usize>,
    pub referer: bool,
    pub max_idle_per_host: Option<usize>,
    pub http2_only: bool,
    pub http1_case_sensitive_headers: bool,
    pub local_address: Option<IpAddr>,
}

A configuration fragment to configure the reqwest Client

This carries configuration used to build a reqwest Client. An empty configuration corresponds to default Client::new(), but most things can be overridden.

The client can be created either manually by methods here, or by pairing it with AtomicClient. See the crate example

Fields

Fields (Non-exhaustive)

Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
user_agent: Option<String>

Set the user agent header.

pool_idle_timeout: Option<Duration>

Timeout for connections sitting unused in the pool.

http2_initial_stream_window_size: Option<u32>

Initial HTTP2 window size.

http2_initial_connection_window_size: Option<u32>

Initial HTTP2 connection window size.

tcp_nodelay: bool

Requires that all sockets used have the SO_NODELAY set.

This improves latency in some cases at the cost of sending more packets.

On by default.

tls_extra_root_certs: Vec<PathBuf>

Additional certificates to add into the TLS trust store.

Certificates in these files will be considered trusted in addition to the system trust store.

Accepts PEM and DER formats (autodetected).

tls_identity: Option<PathBuf>

Client identity.

A file with client certificate and private key that'll be used to authenticate against the server. This needs to be a PKCS12 format.

If not set, no client identity is used.

tls_identity_password: Option<Hidden<String>>

A password for the client identity file.

If tls-identity is not set, the value here is ignored. If not set and the tls-identity is present, an empty password is attempted.

tls_accept_invalid_hostnames: bool

When validating the server certificate, accept even invalid or not matching hostnames.

DANGEROUS

Do not set unless you are 100% sure you have to and know what you're doing. This bypasses part of the protections TLS provides.

Default is false (eg. invalid hostnames are not accepted).

tls_accept_invalid_certs: bool

When validating the server certificate, accept even invalid or untrusted certificates.

DANGEROUS

Do not set unless you are 100% sure you have to and know what you're doing. This bypasses part of the protections TLS provides.

Default is false (eg. invalid certificates are not accepted).

enable_gzip: bool

Enables gzip transport compression.

Default is on.

enable_brotli: bool

Enables brotli transport compression.

Default is on.

default_headers: HashMap<String, String>

Headers added to each request.

This can be used for example to add User-Agent header.

By default no headers are added.

timeout: Option<Duration>

A whole-request timeout.

If the request doesn't happen during this time, it gives up.

The default is 30s. Can be turned off by setting to nil.

connect_timeout: Option<Duration>

A timeout for connecting to the server.

The default is no connection timeout.

http_proxy: Option<Url>

An URL for proxy to use on HTTP requests.

No proxy is used if not set.

https_proxy: Option<Url>

An URL for proxy to use on HTTPS requests.

No proxy is used if not set.

disable_proxy: bool

Disable use of all proxies.

This disables both the proxies configured here and proxy auto-detected from system. Overrides both http_proxy and https_proxy.

redirects: Option<usize>

How many redirects to allow for one request.

The default value is 10. Support for redirects can be completely disabled by setting this to nil.

referer: bool

Manages automatic setting of the Referer header.

Default is on.

max_idle_per_host: Option<usize>

Maximum number of idle connections per one host.

Default is no limit.

http2_only: bool

Use only HTTP/2.

Default is false.

http1_case_sensitive_headers: bool

Use HTTP/1 headers in case sensitive manner.

local_address: Option<IpAddr>

The local address connections are made from.

Default is no address (the OS will choose).

Implementations

impl ReqwestClient[src]

pub fn async_builder(&self) -> Result<ClientBuilder, AnyError>[src]

Creates a pre-configured ClientBuilder

This configures everything according to self and then returns the builder. The caller can modify it further and then create the client.

Unless there's a need to tweak the configuration, the create_async_client is more comfortable.

pub fn blocking_builder(&self) -> Result<BlockingBuilder, AnyError>[src]

Creates a blocking ClientBuilder.

pub fn create_blocking_client(&self) -> Result<BlockingClient, AnyError>[src]

Creates a Client according to the configuration inside self.

This is for manually creating the client. It is also possible to pair with an AtomicClient to form a Pipeline.

pub fn create_async_client(&self) -> Result<Client, AnyError>[src]

Creates a Client according to the configuration inside self.

This is for manually creating the client. It is also possible to pair with an AtomicClient to form a Pipeline.

Trait Implementations

impl Clone for ReqwestClient[src]

impl Debug for ReqwestClient[src]

impl Default for ReqwestClient[src]

impl<'de> Deserialize<'de> for ReqwestClient where
    ReqwestClient: Default
[src]

impl Eq for ReqwestClient[src]

impl Fragment for ReqwestClient[src]

type Driver = CacheEq<ReqwestClient>

The default driver to be used by the fragment. Read more

type Resource = ClientBuilder

The actual product this Fragment creates.

type Installer = ()

The default installer to be used unless a transformation or the user doesn't provide one. Read more

type Seed = ()

The intermediate product if the fragment supports two-stage creation of Resources. If not, it can be set to (). Read more

impl PartialEq<ReqwestClient> for ReqwestClient[src]

impl Serialize for ReqwestClient[src]

impl StructDoc for ReqwestClient[src]

impl StructuralEq for ReqwestClient[src]

impl StructuralPartialEq for ReqwestClient[src]

Auto Trait Implementations

impl RefUnwindSafe for ReqwestClient

impl Send for ReqwestClient

impl Sync for ReqwestClient

impl Unpin for ReqwestClient

impl UnwindSafe for ReqwestClient

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.