Expand description
Network utilities — SSRF protection, HTTP client helpers.
Functions§
- build_
http_ client - Build an HTTP client with the given timeout.
- build_
http_ client_ with_ options - Like
build_http_client, optionally without redirect-following. Blossom PUT usesfalse: a 3xx mid-upload would re-issue as GET and drop the body, so we surface the 3xx as the real failure status. - get_
remote_ file_ size - Get the size of a remote file via HEAD request or Range fallback. Returns None if the URL is private, unreachable, or size can’t be determined.
- rebuild_
shared_ http_ client - Rebuild the shared client. Call this when Tor state flips so the next request goes through the freshly-configured proxy. In-flight requests on the old client continue to completion on the previous Arc.
- shared_
http_ client - Get a shared HTTP client. Cheap clone (Arc), proxy-aware, picks up Tor
toggles on the next call after
rebuild_shared_http_client()runs. - strip_
md_ link_ claims - Rewrite markdown links so a preview-URL scan sees only real DESTINATIONS:
[text](href)keeps the href and drops the display text — a URL claimed in the text must never win the OG preview over where the link actually goes —[text](<href>)drops entirely (angle brackets are the no-preview syntax), and[text][ref]drops the label (its destination is a definition scanned on its own elsewhere in the text). Images () render as literal text in chat, so they pass through untouched. - validate_
url_ not_ private - Reject URLs that resolve to private/loopback/link-local addresses (SSRF protection).