Expand description
§reqkit
A production-focused, client-side HTTP requester built on hyper + rustls.
reqkit aims to be a small, dependable building block for API clients:
- HTTPS-only client (prevents accidental downgrade)
- HTTP/2 preferred, HTTP/1.1 fallback
- Connection pooling for concurrent usage
- One IO timeout that covers request + full body download
- Hard caps for both downloaded bytes and decoded output bytes
- Content decoding for
gzip,deflate, andbr(Brotli) - Convenience request constructors and response decoders (feature-gated)
§Quickstart
use reqkit::{HttpClient, HttpRequest, HeaderMap, Method};
#[tokio::main]
async fn main() -> Result<(), reqkit::HttpError> {
let client = HttpClient::new_https("api.example.com")?;
let req = HttpRequest::empty(Method::GET, "/v1/ping", HeaderMap::new());
let (status, _headers, body) = client.send_bytes_decoded(req).await?;
println!("status={status} body_len={}", body.len());
Ok(())
}§Safety & hardening
- No automatic retries (retry policy is app-specific)
- Body caps apply twice:
- compressed download cap (streamed into memory), and
- decoded output cap (prevents decompression bombs)
§Feature flags
json(default): enables JSON request bodies and JSON decode helpersjson5: enables JSON5 decode helpersform(default): enables x-www-form-urlencoded request bodies
§Notes
HttpClientis scoped to a singlehostand constructshttps://{host}{path}URIs.pathmust start with/.
If you build an API-specific wrapper on top of reqkit, keep retry/backoff, auth, and domain-specific error mapping in your wrapper layer.
Re-exports§
pub use request::HttpRequest;
Modules§
Structs§
- Bytes
- A cheaply cloneable and sliceable chunk of contiguous memory.
- Header
Map - A specialized multimap for header names and values.
- Header
Name - Represents an HTTP header field name
- Header
Value - Represents an HTTP header field value.
- Http
Client - An HTTPS-only, host-scoped client capable of making requests with pooling, timeouts and body caps.
- Method
- The Request Method (VERB)
- Uri
- The URI component of a request.
Enums§
- Http
Error - Errors returned by reqkit.
Functions§
- decode_
content - Decode the response bytes according to
Content-Encoding.