Skip to main content

Module net

Module net 

Source
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 uses false: 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.
validate_url_not_private
Reject URLs that resolve to private/loopback/link-local addresses (SSRF protection).