Expand description
HTTP client factories and URL validation primitives.
Two factories return preconfigured reqwest::ClientBuilders:
safe_client_builder— for clients that send to user-controllable URLs. Caller is expected to validate URLs viaSafeUrl::parsefirst.vendor_client_builder— for clients that send to operator-trusted vendor APIs (Twitter, OpenAI, etc.). No URL validation is implied.
Both builders set redirect(Policy::none()), .no_proxy(), and a
connect_timeout(5s). They also install a custom DNS resolver
(SafeDnsResolver) that re-applies the IP blocklist at connect time
— closing the DNS-rebinding bypass that the parse-time check alone
left open (F-NET-2).
Structs§
- Safe
DnsResolver - Custom DNS resolver that re-validates resolved IPs against the
IpPolicyat connect time. - SafeUrl
- A URL that has passed scheme + IP-blocklist validation.
Enums§
- IpPolicy
- Whether to permit requests to non-routable / private IPs.
Constants§
- DEFAULT_
VENDOR_ BODY_ CAP - Default cap for vendor response bodies (5 MiB).
Functions§
- read_
body_ capped - Read up to
max_bytesfromresponseand return the bytes plus a flag indicating whether truncation happened. - read_
text_ capped - Read response body as text, capped at
max_bytes. Lossy UTF-8 on non-UTF-8 input. - safe_
client_ builder reqwest::ClientBuilderwithredirect(Policy::none()),.no_proxy(),connect_timeout(5s), and aSafeDnsResolverbaked in.- validate_
url_ sync - Synchronous best-effort URL validation: scheme + literal-IP only.
- vendor_
client_ builder reqwest::ClientBuilderwithredirect(Policy::none()),.no_proxy(), andconnect_timeout(5s)baked in.