Skip to main content

Crate reqkit

Crate reqkit 

Source
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, and br (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:
    1. compressed download cap (streamed into memory), and
    2. decoded output cap (prevents decompression bombs)

§Feature flags

  • json (default): enables JSON request bodies and JSON decode helpers
  • json5: enables JSON5 decode helpers
  • form (default): enables x-www-form-urlencoded request bodies

§Notes

  • HttpClient is scoped to a single host and constructs https://{host}{path} URIs.
  • path must 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§

header
HTTP header types
request

Structs§

Bytes
A cheaply cloneable and sliceable chunk of contiguous memory.
HeaderMap
A specialized multimap for header names and values.
HeaderName
Represents an HTTP header field name
HeaderValue
Represents an HTTP header field value.
HttpClient
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§

HttpError
Errors returned by reqkit.

Functions§

decode_content
Decode the response bytes according to Content-Encoding.