kael_http_client
Transport primitives and a ready-to-use HTTP client for Kael applications.
The crate keeps application code on the standard http
request and response types behind an object-safe HttpClient trait. Applications
can provide their own transport or use the included ReqwestClient. Proxy-aware
and base-URL wrappers compose over either choice.
The reqwest feature is enabled by default. Transport implementations that only
need Kael's traits and standard HTTP types can disable default features to avoid
pulling Reqwest and Tokio. The bundled adapter reuses pooled clients for the
standard redirect modes, honors NO_PROXY, and applies 30-second connect and
five-minute total request timeouts.
# #[cfg(feature = "reqwest")]
use kael_http_client::{AsyncBody, HttpClient, Request, ReqwestClient};
# #[cfg(feature = "reqwest")]
# async fn fetch() -> kael_http_client::Result<()> {
let client = ReqwestClient::user_agent("my-app/1.0")?;
let request = Request::get("https://example.com/status")
.body(AsyncBody::empty())?;
let response = client.send(request).await?;
assert!(response.status().is_success());
# Ok(())
# }
Design and limits
- Redirects are disabled by default and can be enabled per request with
HttpRequestExt. ReqwestClientreads standard proxy environment variables and exposes the selected proxy through the transport trait.- The built-in adapter currently buffers request and response bodies with a 256 MiB hard limit. Custom transports can preserve streaming semantics when an application needs a different memory or backpressure policy.
- Enable
test-supportfor a programmable fake client. UseBlockedHttpClientwhen a subsystem must be prevented from reaching the network.
Part of the Kael native application framework. See the Kael documentation for framework-level guides.
License
Licensed under the Apache License, Version 2.0. See LICENSE-APACHE.