Skip to main content

Crate defect_http

Crate defect_http 

Source
Expand description

HTTP infrastructure shared across modules.

A thin wrapper on top of client_util::build_https_client that adds: timeouts, transport retry with jitter, HTTP/HTTPS proxy support, and a unified User-Agent. HTTP client abstraction for the agent.

Current consumers: defect-llm (various LLM providers); planned: defect-tools’ fetch tool. This layer is extracted into its own crate to prevent the latter from depending on defect-llm (which would create an inverted dependency).

Public entry points are only build_http_stack, HttpStackConfig, HttpStack, and HttpStackError. Concrete layer implementations live in submodules as pub(crate) and are not exposed outside the crate — callers see only a type-erased Service.

Structs§

FetchHttpClient
HTTP client backing the fetch utility.
HttpStackConfig
HTTP stack configuration.
ProxySettings
Explicit proxy settings. http_proxy / https_proxy may each be None; no_proxy is a list of domain suffixes (following the GNU NO_PROXY convention).

Enums§

HttpStackError
HTTP stack-layer error.
ProxyConfig
Proxy configuration.
TimeoutPhase
Timeout phase. Mirrors defect_agent::llm::TimeoutPhase, but this crate does not reference the agent’s type internally to avoid coupling the layer implementation to the LLM error model.

Functions§

build_default_fetch_client_arc
Minimal version – allows the CLI to set up a fetch client even when a full HttpStackConfig is not available.
build_fetch_client
Builds a fetch client from an HttpStackConfig.
build_fetch_client_arc
Convenience wrapper around build_fetch_client + Arc::new — the common path used at CLI assembly points.
build_http_stack
Builds the full HTTP stack; the result can be fed directly to toac::ApiClient::new.
build_proxy_connector
Build a full connector from ProxyConfig.
default_user_agent
The default User-Agent value is defect-http/{CARGO_PKG_VERSION} ({DEFECT_HTTP_GIT_SHA}).

Type Aliases§

HttpStack
Type-erased service returned by build_http_stack.
ProxyAwareConnector
The full connector type used by upper layers to construct a hyper_util::client::legacy::Client.