pub struct HttpTransportBuilder { /* private fields */ }Expand description
Builds an HttpTransport.
Header values are validated when HttpTransportBuilder::build is called,
so a chain of setters stays a chain and does not thread a Result through
every step.
Implementations§
Source§impl HttpTransportBuilder
impl HttpTransportBuilder
Sourcepub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, name: impl Into<String>, value: impl Into<String>) -> Self
Adds a header to every request — an API key, a tenant id, a trace header.
Sourcepub fn headers<K, V>(self, headers: impl IntoIterator<Item = (K, V)>) -> Self
pub fn headers<K, V>(self, headers: impl IntoIterator<Item = (K, V)>) -> Self
Adds several headers.
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Bounds the whole run: connecting, headers, and streaming the body.
An agent that thinks for longer than this has its stream cut off, so a
long-running agent wants HttpTransportBuilder::connect_timeout
instead.
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Bounds only connection setup, leaving the stream itself unbounded.
Sourcepub fn allow_insecure_http(self, allow: bool) -> Self
pub fn allow_insecure_http(self, allow: bool) -> Self
Allows custom headers, URL user information, query strings, or a custom client on a remote HTTP connection. These can carry credentials. HTTPS and loopback HTTP endpoints can use them by default.
Sourcepub fn client(self, client: Client) -> Self
pub fn client(self, client: Client) -> Self
Uses a caller-supplied client, for proxies, custom TLS roots, or a connection pool shared with the rest of an application.
The supplied client retains its redirect policy. Choose that policy carefully: redirects can resend the request body and custom headers.
Sourcepub fn build(self) -> Result<HttpTransport>
pub fn build(self) -> Result<HttpTransport>
Builds the transport.
§Errors
Error::Config when the URL, a header name, or a header value is not
valid, when remote HTTP requires explicit opt-in,
or when the HTTP client cannot be built.