Skip to main content

agent

Function agent 

Source
pub fn agent() -> Agent
Expand description

Create a new HTTP agent configured with native-tls and a global timeout.

This explicitly configures native-tls as the TLS provider, which uses the system’s TLS library (Schannel on Windows, OpenSSL on Linux, Security.framework on macOS).

We use PlatformVerifier to use the system’s built-in root certificates.

A global timeout of 30 seconds is applied to prevent hanging on unresponsive servers. Callers reading response bodies should use body.with_config().limit(N) to enforce size limits.

https_only(true) means a redirect that downgrades the chain to plain HTTP fails instead of being followed. This agent still follows redirects itself, so it does not revalidate the host per hop; callers that need that must use get_validated.