Skip to main content

rightkit_http/
lib.rs

1//! `rightkit-http`: the shared blocking HTTP client for Right Suite apps.
2//!
3//! - [`Client`]: timeouts, bounded bodies, retry/backoff honoring `Retry-After`,
4//!   retry-safety rules for non-idempotent methods, streaming responses.
5//! - [`Multipart`]: `multipart/form-data` bodies with exact framing.
6//! - [`netpolicy`]: the outbound address policy (SSRF guard) every request passes: resolve once,
7//!   classify every address, connect only to checked addresses, on every redirect hop.
8//! - [`CancelToken`]: cooperative cancellation for calls and streams.
9//! - [`sse`]: WHATWG-compliant Server-Sent Events decoding.
10//! - `untrusted` (feature, off by default): tamper-evident wrapping of external text for model input.
11//! - [`secret`]: redacted [`Secret`], the [`SecretStore`] interface and the in-memory
12//!   [`MemorySecretStore`] (no production implementation ships in this crate).
13//! - [`ApprovedOrigins`], [`check_redirect_target`] and [`RedirectRefusal`]: the redirect origin
14//!   allowlist (`Request::approved_redirect_origins`), its typed error
15//!   ([`HttpError::RedirectRefused`]) and a string-level guard for other transports.
16//! - `async_client` (feature `async`): [`AsyncClient`], the same policy layer on
17//!   reqwest/tokio, with a body [`BodyStream`] and an async [`SseStream`].
18//! - `testing` (feature): in-process mock server that records exact requests.
19
20#[cfg(feature = "async")]
21pub mod async_client;
22pub mod cancel;
23pub mod client;
24pub mod error;
25mod idle;
26pub mod multipart;
27pub mod netpolicy;
28pub mod quota;
29mod redirect;
30pub mod retry;
31pub mod secret;
32pub mod sse;
33mod system_proxy;
34mod trust;
35#[cfg(feature = "untrusted")]
36pub mod untrusted;
37mod urlredact;
38
39#[cfg(feature = "testing")]
40pub mod testing;
41
42pub use cancel::{is_cancelled_io, CancelToken};
43pub use client::{
44    form_encode, percent_decode, percent_decode_component, percent_encode,
45    percent_encode_component, AttemptDelivery, AttemptEvent, AttemptOutcome, Client, ClientConfig,
46    Method, ProxyDiagnostic, ProxyMode, ProxyModeUsed, Request, Response, ResponseHead, RetryEvent,
47    StreamResponse, TrustRoots,
48};
49pub use error::{ErrorClass, HttpError, Phase};
50pub use multipart::{Multipart, MultipartRelated};
51pub use netpolicy::{
52    check_redirect_target, parse_host_ip, parse_legacy_ipv4, validate_public_https_url,
53    AddressClass, AddressPolicy, ApprovedOrigins, CredentialScope, HostIpKind, IpNet, ParsedHostIp,
54    RedirectRefusal, ResolveError, UrlPolicyError,
55};
56pub use quota::{defer_in, remaining_in, QuotaSchedule, QuotaStore};
57pub use retry::{
58    parse_rate_limit_reset, parse_rate_limit_reset_at, parse_retry_after, parse_retry_after_at,
59    RetryPolicy,
60};
61pub use secret::{MemorySecretStore, Secret, SecretError, SecretStore};
62pub use sse::{EofPolicy, SseDecoder, SseEvent, SseReader};
63#[cfg(feature = "untrusted")]
64pub use untrusted::{
65    wrap_untrusted_web_text, wrap_untrusted_web_text_coderight, wrap_untrusted_web_text_with,
66    WrapOptions,
67};
68
69#[cfg(feature = "async")]
70pub use async_client::{AsyncClient, AsyncStreamResponse, BodyStream, SseStream};