Skip to main content

Module http

Module http 

Source
Expand description

Shared HTTP client factory and helpers for downloads and JSON index fetches.

Functionsยง

client
Build the shared reqwest client (rustls, gzip, redirects, sane timeouts).
get_cached_github_json
GitHub API variant of get_cached_json, preserving GitHub headers and token handling while adding stale/offline cache behavior.
get_cached_github_json_from_urls
Cached GitHub JSON with transport failover. cache_identity is the canonical upstream URL, so direct and proxied transports share one cache.
get_cached_json
Fetch JSON with a persistent URL-keyed cache. Online requests refresh the cache; failures fall back to stale data. Offline mode never makes a request.
get_cached_source_json
Fetch cached JSON with explicitly configured source headers.
get_cached_text
Fetch text with the same stale-cache behavior as get_cached_json.
get_cached_text_from_urls
Fetch public GitHub Web metadata through ordered transports, sharing one canonical cache entry and retaining stale/offline behavior. Unlike API requests this deliberately sends neither API headers nor authorization.
get_github_json
Fetch JSON from the GitHub API with the recommended headers, honoring a GITHUB_TOKEN/GH_TOKEN env var to raise the rate limit when present. GitHub returns 403 for API requests missing an Accept/X-GitHub-Api-Version header under load, so we always send them.
get_github_json_from_urls
Try multiple transports for one GitHub JSON resource. Authorization is sent only to the official GitHub API host, never to a third-party proxy.
get_json
Fetch a URL and deserialize the JSON body.
get_text
Fetch a URL and return the body as text.
github_token
Read a GitHub token from the usual env vars, if set and non-empty.
github_url_candidates
Build unique candidate transports in source order for one GitHub resource.
github_url_for_source
Rewrite an official GitHub API, raw-content, or release URL through one configured source. Sources whose bases embed the canonical GitHub URL (such as https://gh-proxy.com/https://github.com/) also proxy raw content.
join_url
Join a base URL (which may or may not end in /) with a path tail.
render_template
Substitute {version}, {os}, {arch}, {file}, {ext} placeholders in a URL template. Joins base + tail if the template ends with /.