[−][src]Struct spirit_reqwest::ReqwestClient
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
extra-root-certs
: Array of paths, all will be loaded and added to the default certification store. Can be either PEM or DER.tls-identity
: A client identity to use to authenticate to the server. Needs to be a PKCS12 DER bundle. A password might be specified by thetls-identity-password
field.tls-accept-invalid-hostnames
: If set to true, it accepts invalid hostnames on https. Dangerous, avoid if possible (default isfalse
).tls-accept-invalid-certs
: Allow accepting invalid https certificates. Dangerous, avoid if possible (default isfalse
).enable-gzip
: Enable gzip compression of transferred data. Default istrue
.enable-brotli
: Enable brotli compression of transferred data. Default istrue
.default-headers
: A bundle of headers a request starts with. Map of name-value, defaults to empty.user-agent
: The user agent to send with requests.timeout
: Default whole-request timeout. Can be a time specification (with units) ornil
for no timeout. Default is30s
.connect-timeout
: Timeout for the connection phase of a request (with units) ornil
for no such timeout. Default is no timeout.max-idle-per-host
: Maximal number of idle connection per one host in the pool. Defaults tonil
(no limit).pool-idle-timeout
: How long to keep unused connections around (nil
to no limit`).http2-only
: Use only HTTP/2. Default is false (both HTTP/1 and HTTP/2 are allowed).http2-initial-stream-window-size
,http2-initial-connection-window-size
: Tweak the low level TCP options.http1-case-sensitive-headers
: Consider HTTP/1 headers case sensitive.local-address
: Make the requests from this address. Default isnil
, which lets the OS to choose.http-proxy
: An URL of proxy that serves http requests.https-proxy
: An URL of proxy that servers https requests.disable-proxy
: If set to true, disables all use of proxy (including auto-detected system one).redirects
: Number of allowed redirects per one request,nil
to disable. Defaults to10
.referer
: Allow automatic setting of the referer header. Defaults totrue
.tcp-nodelay
: Use theSO_NODELAY
flag on all connections.
Fields (Non-exhaustive)
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]
fn clone(&self) -> ReqwestClient
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ReqwestClient
[src]
impl Default for ReqwestClient
[src]
impl<'de> Deserialize<'de> for ReqwestClient where
ReqwestClient: Default,
[src]
ReqwestClient: Default,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
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
Resource
s. If not, it can be set to ()
. Read more
fn make_seed(&self, _: &'static str) -> Result<(), AnyError>
[src]
fn make_resource(
&self,
_: &mut (),
_: &'static str
) -> Result<ClientBuilder, AnyError>
[src]
&self,
_: &mut (),
_: &'static str
) -> Result<ClientBuilder, AnyError>
const RUN_BEFORE_CONFIG: bool
[src]
fn create(
&self,
name: &'static str
) -> Result<Self::Resource, Box<dyn Error + 'static + Sync + Send>>
[src]
&self,
name: &'static str
) -> Result<Self::Resource, Box<dyn Error + 'static + Sync + Send>>
fn init<B>(
builder: B,
&'static str
) -> Result<B, Box<dyn Error + 'static + Sync + Send>> where
B: Extensible<Ok = B>,
<B as Extensible>::Config: DeserializeOwned,
<B as Extensible>::Config: Send,
<B as Extensible>::Config: Sync,
<B as Extensible>::Config: 'static,
<B as Extensible>::Opts: StructOpt,
<B as Extensible>::Opts: Send,
<B as Extensible>::Opts: Sync,
<B as Extensible>::Opts: 'static,
[src]
builder: B,
&'static str
) -> Result<B, Box<dyn Error + 'static + Sync + Send>> where
B: Extensible<Ok = B>,
<B as Extensible>::Config: DeserializeOwned,
<B as Extensible>::Config: Send,
<B as Extensible>::Config: Sync,
<B as Extensible>::Config: 'static,
<B as Extensible>::Opts: StructOpt,
<B as Extensible>::Opts: Send,
<B as Extensible>::Opts: Sync,
<B as Extensible>::Opts: 'static,
impl PartialEq<ReqwestClient> for ReqwestClient
[src]
fn eq(&self, other: &ReqwestClient) -> bool
[src]
fn ne(&self, other: &ReqwestClient) -> bool
[src]
impl Serialize for ReqwestClient
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructDoc for ReqwestClient
[src]
fn document() -> Documentation
[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoResult<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,