pub struct TransportBuilder { /* private fields */ }Expand description
Configures a Transport. Requests have a 60 second timeout, a 10 second
connect timeout and a 32 MiB response limit unless changed here.
Debug output omits credentials, header values and proxy passwords.
Implementations§
Source§impl TransportBuilder
impl TransportBuilder
Sourcepub fn new(url: Url) -> Self
pub fn new(url: Url) -> Self
Every request path is appended to url, so a reverse-proxy base path is preserved.
pub fn auth(self, credentials: Credentials) -> Self
Sourcepub fn header(self, name: HeaderName, value: HeaderValue) -> Self
pub fn header(self, name: HeaderName, value: HeaderValue) -> Self
Sends a header with every request, replacing earlier values of the same name.
Headers are combined in this order, each replacing every earlier value
of a name it sets: built-in defaults and credentials, these transport
headers, the body’s Content-Type, then per-request headers.
Sourcepub fn headers(self, headers: HeaderMap) -> Self
pub fn headers(self, headers: HeaderMap) -> Self
Sends these headers with every request. Each name replaces earlier values
of that name; repeated values of one name in headers are all sent.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
The total time allowed for a request, including reading the body.
pub fn connect_timeout(self, timeout: Duration) -> Self
Sourcepub fn root_certificate(self, certificate: Certificate) -> Self
pub fn root_certificate(self, certificate: Certificate) -> Self
Trusts an additional root certificate alongside the platform roots.
Sourcepub fn proxy(self, url: Url) -> Self
pub fn proxy(self, url: Url) -> Self
Routes every request through this proxy. Credentials may be embedded in the URL.
Sourcepub fn disable_proxy(self) -> Self
pub fn disable_proxy(self) -> Self
Ignores proxy environment variables such as HTTPS_PROXY, which are honored by default.
Sourcepub fn response_limit(self, bytes: usize) -> Self
pub fn response_limit(self, bytes: usize) -> Self
The largest body Response::json, bytes and text will read.
Streaming with Response::bytes_stream bypasses this limit.
A zero limit fails when Self::build is called.
Sourcepub fn build(self) -> Result<Transport>
pub fn build(self) -> Result<Transport>
Builds the connection pool and validates its settings. Invalid base URLs,
credentials, certificates or proxy settings return Error::Configuration.