Skip to main content

Module http

Module http 

Source
Expand description

HTTP client with retry, caching, and rate limiting.

All requests are queued and driven by tick(). Results arrive as HttpEvent values polled from drain_events(). Each request runs on a short-lived background thread using ureq (rustls for HTTPS, no OpenSSL), so tick() never blocks the frame.

The network backend needs the http cargo feature. Without it every request fails at once with HttpError::InvalidRequest saying so; before 0.3.0 every request was instead answered with a made-up empty 200 OK.

§Features

  • GET, POST, PUT, DELETE, PATCH
  • Per-request timeout
  • Retry with exponential backoff and jitter
  • In-memory response cache (ETag / Last-Modified)
  • Rate limiter (token bucket per base URL)
  • JSON body helpers
  • Binary response support

Structs§

HttpClient
Non-blocking HTTP client driven by tick().
HttpRequest
An HTTP request to be issued by the client.
HttpResponse
A response from the server (or from the cache).
RateLimiter
Token-bucket rate limiter per base URL.
RequestId
Identifies one request across its retries and events.

Enums§

CachePolicy
How a GET request uses the response cache.
HttpError
Why a request failed.
HttpEvent
Something that happened to a request, from HttpClient::drain_events.
Method
HTTP request method.