Module http_client

Module http_client 

Source
Expand description

Common types and utilities for HTTP client providers.

This module provides a reusable connection pooling implementation that can be used by both the internal and external wasmCloudHTTP client providers. It manages separate pools for HTTP and HTTPS connections, allowing for efficient connection reuse.

Structs§

ConnPool
Manages separate pools for HTTP and HTTPS connections, allowing for efficient connection reuse based on the target authority.
PooledConn
Represents a connection to a remote HTTP server that can be reused across multiple requests. Includes the actual sender for making requests, a handle to abort the connection task, and a timestamp for tracking when the connection was last used for connection pooling.

Enums§

Cacheable
Represents a cacheable result that can either be a miss or a hit. Used to handle connection caching in the HTTP client provider.

Constants§

DEFAULT_CONNECT_TIMEOUT
Default HTTP connection timeout.
DEFAULT_FIRST_BYTE_TIMEOUT
Default first byte timeout for HTTP connections (causingHTTP 503 errors).
DEFAULT_IDLE_TIMEOUT
Default duration after which idle connections are closed.
DEFAULT_USER_AGENT
Default User-Agent header value for HTTP requests.
LOAD_NATIVE_CERTS
Configuration key to control whether to load the system’s native certificate store. When set to “true” (default), the provider will use the operating system’s trusted certificates.
LOAD_WEBPKI_CERTS
Configuration key to control whether to load the webpki certificate store. When set to “true”, the provider will use the Mozilla-curated certificate store bundled with webpki-roots.
SSL_CERTS_FILE
Configuration key to specify a custom TLS certificate CA bundle file. When provided, the provider will load certificates from this file in addition to other sources.

Statics§

ZERO_INSTANT
Instant used as the “zero” last_seen value. Provides a consistent starting point for measuring connection age.

Functions§

evict_conns
Evicts connections from the pool that have been idle for longer than the cutoff time.
hyper_request_error
Translate a hyper::Error to a wRPC HTTP error code.

Type Aliases§

ConnPoolTable
Type alias for the connection pool’s internal storage structure. Maps authority strings (e.g., “example.com:443”) to queues of pooled connections for efficient connection reuse.