pub struct ConfigBuilder<Scope: ConfigScope>(/* private fields */);Expand description
Builder of Config
Implementations§
Source§impl<Scope: ConfigScope> ConfigBuilder<Scope>
impl<Scope: ConfigScope> ConfigBuilder<Scope>
Sourcepub fn http_status_as_error(self, v: bool) -> Self
pub fn http_status_as_error(self, v: bool) -> Self
Whether to treat 4xx and 5xx HTTP status codes as
Err(Error::StatusCode)).
Defaults to true.
Sourcepub fn https_only(self, v: bool) -> Self
pub fn https_only(self, v: bool) -> Self
Whether to limit requests (including redirects) to https only
Defaults to false.
Sourcepub fn ip_family(self, v: IpFamily) -> Self
pub fn ip_family(self, v: IpFamily) -> Self
Configuration of IPv4/IPv6.
This affects the resolver.
Defaults to IpFamily::Any.
Sourcepub fn tls_config(self, v: TlsConfig) -> Self
pub fn tls_config(self, v: TlsConfig) -> Self
Config for TLS.
This config is generic for all TLS connectors.
Sourcepub fn proxy(self, v: Option<Proxy>) -> Self
pub fn proxy(self, v: Option<Proxy>) -> Self
Proxy configuration.
Picked up from environment when using Config::default() or
Agent::new_with_defaults().
Sourcepub fn no_delay(self, v: bool) -> Self
pub fn no_delay(self, v: bool) -> Self
Disable Nagle’s algorithm
Set TCP_NODELAY. It’s up to the transport whether this flag is honored.
Defaults to true.
Sourcepub fn max_redirects(self, v: u32) -> Self
pub fn max_redirects(self, v: u32) -> Self
The max number of redirects to follow before giving up.
Whe max redirects are reached, the behavior is controlled by the
max_redirects_will_error setting. Set to true (which
is the default) the result is a TooManyRedirects error. Set
to false, the response is returned as is.
If max_redirects is 0, no redirects are followed and the response
is always returned (never a TooManyRedirects error).
Defaults to 10
Sourcepub fn max_redirects_will_error(self, v: bool) -> Self
pub fn max_redirects_will_error(self, v: bool) -> Self
If we should error when max redirects are reached.
This has no meaning if max_redirects is 0.
Defaults to true
Sourcepub fn redirect_auth_headers(self, v: RedirectAuthHeaders) -> Self
pub fn redirect_auth_headers(self, v: RedirectAuthHeaders) -> Self
How to handle Authorization headers when following redirects
Never(the default) means the authorization header is never attached to a redirected call.SameHostwill keep the header when the redirect is to the same host and under https.
Defaults to None.
Sourcepub fn save_redirect_history(self, v: bool) -> Self
pub fn save_redirect_history(self, v: bool) -> Self
If we should record a history of every redirect location, including the request and final locations.
Comes at the cost of allocating/retaining the Uri for
every redirect loop.
See ResponseExt::get_redirect_history().
Defaults to false.
Sourcepub fn user_agent(self, v: impl Into<AutoHeaderValue>) -> Self
pub fn user_agent(self, v: impl Into<AutoHeaderValue>) -> Self
Value to use for the User-Agent header.
This can be overridden by setting a user-agent header on the request
object. The one difference is that a connection to a HTTP proxy server
will receive this value, not the request-level one.
Setting a value of "" on the request or agent level will also not send a header.
Defaults to Default, which results in ureq/<version>
Sourcepub fn accept(self, v: impl Into<AutoHeaderValue>) -> Self
pub fn accept(self, v: impl Into<AutoHeaderValue>) -> Self
Value to use for the Accept header.
This agent configured value can be overriden per request by setting the header.
Setting a value of "" on the request or agent level will also not send a header.
Defaults to Default, which results in */*
Sourcepub fn accept_encoding(self, v: impl Into<AutoHeaderValue>) -> Self
pub fn accept_encoding(self, v: impl Into<AutoHeaderValue>) -> Self
Value to use for the Accept-Encoding header.
Defaults to Default, which will add gz and brotli depending on
the feature flags gzip and brotli respectively. If neither
feature is enabled, the header is not added.
This agent configured value can be overriden per request by setting the header.
Setting a value of "" on the request or agent level will also not send a header.
This communicates capability to the server, however the triggering the
automatic decompression behavior is not affected since that only looks
at the Content-Encoding response header.
Sourcepub fn max_response_header_size(self, v: usize) -> Self
pub fn max_response_header_size(self, v: usize) -> Self
Max size of the HTTP response header.
From the status, including all headers up until the body.
Defaults to 64kb.
Sourcepub fn input_buffer_size(self, v: usize) -> Self
pub fn input_buffer_size(self, v: usize) -> Self
Default size of the input buffer
The default connectors use this setting.
Defaults to 128kb.
Sourcepub fn output_buffer_size(self, v: usize) -> Self
pub fn output_buffer_size(self, v: usize) -> Self
Default size of the output buffer.
The default connectors use this setting.
Defaults to 128kb.
Sourcepub fn max_idle_connections(self, v: usize) -> Self
pub fn max_idle_connections(self, v: usize) -> Self
Max number of idle pooled connections overall.
This setting has no effect when used per-request.
Defaults to 10
Sourcepub fn max_idle_connections_per_host(self, v: usize) -> Self
pub fn max_idle_connections_per_host(self, v: usize) -> Self
Max number of idle pooled connections per host/port combo.
This setting has no effect when used per-request.
Defaults to 3
Sourcepub fn max_idle_age(self, v: Duration) -> Self
pub fn max_idle_age(self, v: Duration) -> Self
Max duration to keep an idle connection in the pool
This can also be configured per-request to be shorter than the pool. For example: if the pool is configured to 15 seconds and we have a connection with an age of 10 seconds, a request setting this config property to 3 seconds, would ignore the pooled connection (but still leave it in the pool).
Defaults to 15 seconds
Sourcepub fn allow_non_standard_methods(self, v: bool) -> Self
pub fn allow_non_standard_methods(self, v: bool) -> Self
Whether to allow non-standard HTTP methods.
By default the methods are limited by the HTTP version.
Defaults to false
Sourcepub fn middleware(self, v: impl Middleware) -> Self
pub fn middleware(self, v: impl Middleware) -> Self
Add middleware to use for each request in this agent.
Defaults to no middleware.
Sourcepub fn timeout_global(self, v: Option<Duration>) -> Self
pub fn timeout_global(self, v: Option<Duration>) -> Self
Timeout for the entire call
This is end-to-end, from DNS lookup to finishing reading the response body. Thus it covers all other timeouts.
Defaults to None.
Sourcepub fn timeout_per_call(self, v: Option<Duration>) -> Self
pub fn timeout_per_call(self, v: Option<Duration>) -> Self
Timeout for call-by-call when following redirects
This covers a single call and the timeout is reset when ureq follows a redirections.
Defaults to None..
Sourcepub fn timeout_resolve(self, v: Option<Duration>) -> Self
pub fn timeout_resolve(self, v: Option<Duration>) -> Self
Max duration for doing the DNS lookup when establishing the connection
Because most platforms do not have an async syscall for looking up a host name, setting this might force str0m to spawn a thread to handle the timeout.
Defaults to None.
Sourcepub fn timeout_connect(self, v: Option<Duration>) -> Self
pub fn timeout_connect(self, v: Option<Duration>) -> Self
Max duration for establishing the connection
For a TLS connection this includes opening the socket and doing the TLS handshake.
Defaults to None.
Sourcepub fn timeout_send_request(self, v: Option<Duration>) -> Self
pub fn timeout_send_request(self, v: Option<Duration>) -> Self
Max duration for sending the request, but not the request body.
Defaults to None.
Sourcepub fn timeout_await_100(self, v: Option<Duration>) -> Self
pub fn timeout_await_100(self, v: Option<Duration>) -> Self
Max duration for awaiting a 100-continue response.
Only used if there is a request body and we sent the Expect: 100-continue
header to indicate we want the server to respond with 100.
This defaults to 1 second.
Sourcepub fn timeout_send_body(self, v: Option<Duration>) -> Self
pub fn timeout_send_body(self, v: Option<Duration>) -> Self
Max duration for sending a request body (if there is one)
Defaults to None.
Sourcepub fn timeout_recv_response(self, v: Option<Duration>) -> Self
pub fn timeout_recv_response(self, v: Option<Duration>) -> Self
Max duration for receiving the response headers, but not the body
Defaults to None.
Sourcepub fn timeout_recv_body(self, v: Option<Duration>) -> Self
pub fn timeout_recv_body(self, v: Option<Duration>) -> Self
Max duration for receving the response body.
Defaults to None.
Source§impl<Any> ConfigBuilder<RequestScope<Any>>
impl<Any> ConfigBuilder<RequestScope<Any>>
Sourcepub fn build(self) -> RequestBuilder<Any>
pub fn build(self) -> RequestBuilder<Any>
Finalize the config