packages

http::client

On this page

The client: connection pool, HTTP/1.1 keep-alive, HTTP/2 over TLS (ALPN) or by prior knowledge, redirects, timeouts.

Structs

ClientConfigSource

pub struct ClientConfig

Client settings. Every field has a default.

  • pub timeout: Duration | none = Duration::secs(30)§

    Source

    Time from sending a request to its response head (per hop).

  • pub connect_timeout: Duration | none = Duration::secs(10)§

    Source
  • pub read_timeout: Duration | none = Duration::secs(30)§

    Source

    Longest wait for one read of a response body.

  • pub max_redirects: u32 = 10u32§

    Source

    Redirects followed; 0 returns 3xx responses as they are.

  • pub version: Version = Version::Http11§

    Source

    Http11, or Http2 to speak HTTP/2 to http URLs by prior knowledge (h2c). https URLs offer both through ALPN and use HTTP/2 when the server picks it.

  • pub max_idle_per_host: usize = 8§

    Source

    Idle HTTP/1.1 connections kept per origin.

  • pub idle_timeout: Duration = Duration::secs(90)§

    Source

    Idle connections older than this are not reused.

  • pub user_agent: str | none = "nabi-http/0.2"§

    Source

    Sent as User-Agent unless the request has one.

  • pub limits: Limits = Limits {}§

    Source
  • pub h2: h2::Config = h2::Config {}§

    Source

ClientSource

pub struct Client

An HTTP client. Copies share the connection pool.

Functions

getSource

pub async fn get(url: str) throws (HttpError) -> Response

GET url with a default client.