#[non_exhaustive]pub struct ReqwestClientOptions {
pub connect_timeout: Duration,
pub default_timeout: Duration,
pub max_cached_clients: usize,
pub default_user_agent: Option<String>,
pub header_generator: Arc<HeaderGenerator>,
}Expand description
Configuration for ReqwestClient.
§Examples
use std::time::Duration;
use millipede_http::ReqwestClientOptions;
let options = ReqwestClientOptions::default()
.with_connect_timeout(Duration::from_secs(5))
.with_default_timeout(Duration::from_secs(20))
.with_max_cached_clients(4)
.with_default_user_agent(None);
let client = millipede_http::ReqwestClient::with_options(options)?;Fields (Non-exhaustive)§
This struct is marked as 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.connect_timeout: DurationMaximum time allowed while establishing a connection.
default_timeout: DurationRequest timeout used when a request does not provide one.
max_cached_clients: usizeMaximum number of proxy-specific clients retained in the simple cache.
default_user_agent: Option<String>User-Agent inserted when a request does not already contain one.
header_generator: Arc<HeaderGenerator>Generator used for deterministic browser-like request headers.
Implementations§
Source§impl ReqwestClientOptions
impl ReqwestClientOptions
Sourcepub fn with_connect_timeout(self, timeout: Duration) -> Self
pub fn with_connect_timeout(self, timeout: Duration) -> Self
Sets the connection timeout.
Sourcepub fn with_default_timeout(self, timeout: Duration) -> Self
pub fn with_default_timeout(self, timeout: Duration) -> Self
Sets the default request timeout.
Sourcepub fn with_max_cached_clients(self, maximum: usize) -> Self
pub fn with_max_cached_clients(self, maximum: usize) -> Self
Sets the maximum number of cached clients.
Sourcepub fn with_default_user_agent(self, user_agent: Option<String>) -> Self
pub fn with_default_user_agent(self, user_agent: Option<String>) -> Self
Sets or disables the default User-Agent.
Sourcepub fn with_header_generator(self, generator: Arc<HeaderGenerator>) -> Self
pub fn with_header_generator(self, generator: Arc<HeaderGenerator>) -> Self
Replaces the deterministic browser-like header generator.
Trait Implementations§
Source§impl Clone for ReqwestClientOptions
impl Clone for ReqwestClientOptions
Source§fn clone(&self) -> ReqwestClientOptions
fn clone(&self) -> ReqwestClientOptions
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ReqwestClientOptions
impl Debug for ReqwestClientOptions
Auto Trait Implementations§
impl Freeze for ReqwestClientOptions
impl RefUnwindSafe for ReqwestClientOptions
impl Send for ReqwestClientOptions
impl Sync for ReqwestClientOptions
impl Unpin for ReqwestClientOptions
impl UnsafeUnpin for ReqwestClientOptions
impl UnwindSafe for ReqwestClientOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more