pub struct Options {
pub redirect_policy: RedirectPolicy,
pub preferred_http_version: Option<Version>,
pub timeout: Option<Duration>,
pub connect_timeout: Duration,
pub tcp_keepalive: Option<Duration>,
pub tcp_nodelay: bool,
pub buffer_size: usize,
pub auto_referer: bool,
pub proxy: Option<Uri>,
pub max_upload_speed: Option<u64>,
pub max_download_speed: Option<u64>,
}
Expand description
Defines various protocol and connection options.
Fields
redirect_policy: RedirectPolicy
The policy for automatically following server redirects.
The default is to not follow redirects.
preferred_http_version: Option<Version>
A preferred HTTP version the client should attempt to use to communicate to the server with.
This is treated as a suggestion. A different version may be used if the server does not support it or negotiates a different version.
The default value is None
(any version).
timeout: Option<Duration>
A timeout for the maximum time allowed for a request-response cycle.
The default value is None
(unlimited).
connect_timeout: Duration
A timeout for the initial connection phase.
The default value is 300 seconds.
tcp_keepalive: Option<Duration>
Enable or disable TCP keepalive with a given probe interval.
The default value is None
(disabled).
tcp_nodelay: bool
Enable or disable the TCP_NODELAY
option.
The default value is false
.
buffer_size: usize
Set the max buffer size in bytes to use for reading the response body.
The default value is 8 KiB.
auto_referer: bool
Indicates whether the Referer
header should be automatically updated.
proxy: Option<Uri>
A proxy to use for requests.
The proxy protocol is specified by the URI scheme.
http
: Proxy. Default when no scheme is specified.https
: HTTPS Proxy. (Added in 7.52.0 for OpenSSL, GnuTLS and NSS)socks4
: SOCKS4 Proxy.socks4a
: SOCKS4a Proxy. Proxy resolves URL hostname.socks5
: SOCKS5 Proxy.socks5h
: SOCKS5 Proxy. Proxy resolves URL hostname.
max_upload_speed: Option<u64>
A maximum upload speed for the request body, in bytes per second.
The default is unlimited.
max_download_speed: Option<u64>
A maximum download speed for the response body, in bytes per second.
The default is unlimited.
Implementations
sourceimpl Options
impl Options
sourcepub fn with_redirect_policy(self, value: RedirectPolicy) -> Self
pub fn with_redirect_policy(self, value: RedirectPolicy) -> Self
Sets the #name property.
sourcepub fn with_preferred_http_version(self, value: Option<Version>) -> Self
pub fn with_preferred_http_version(self, value: Option<Version>) -> Self
Sets the #name property.
sourcepub fn with_timeout(self, value: Option<Duration>) -> Self
pub fn with_timeout(self, value: Option<Duration>) -> Self
Sets the #name property.
sourcepub fn with_connect_timeout(self, value: Duration) -> Self
pub fn with_connect_timeout(self, value: Duration) -> Self
Sets the #name property.
sourcepub fn with_tcp_keepalive(self, value: Option<Duration>) -> Self
pub fn with_tcp_keepalive(self, value: Option<Duration>) -> Self
Sets the #name property.
sourcepub fn with_tcp_nodelay(self, value: bool) -> Self
pub fn with_tcp_nodelay(self, value: bool) -> Self
Sets the #name property.
sourcepub fn with_buffer_size(self, value: usize) -> Self
pub fn with_buffer_size(self, value: usize) -> Self
Sets the #name property.
sourcepub fn with_auto_referer(self, value: bool) -> Self
pub fn with_auto_referer(self, value: bool) -> Self
Sets the #name property.
sourcepub fn with_proxy(self, value: Option<Uri>) -> Self
pub fn with_proxy(self, value: Option<Uri>) -> Self
Sets the #name property.
sourcepub fn with_max_upload_speed(self, value: Option<u64>) -> Self
pub fn with_max_upload_speed(self, value: Option<u64>) -> Self
Sets the #name property.
sourcepub fn with_max_download_speed(self, value: Option<u64>) -> Self
pub fn with_max_download_speed(self, value: Option<u64>) -> Self
Sets the #name property.