module

Hwaro::Core::Build::RemoteFetch

Constants

CONNECT_TIMEOUT = 10.seconds
MAX_REDIRECTS = 5
READ_TIMEOUT = 30.seconds

Instance methods

fetch(url : String, headers : Hash(String, String), max_bytes : Int64, deadline : Time::Span, user_agent : String = "Hwaro", guard : URI -> Array(String) | Nil | Nil = nil) : Tuple(String, String | Nil, String)

Returns the body, the response Content-Type, and the FINAL url — the one the last hop actually served. url is returned verbatim (not round-tripped through URI) when no redirect moved it.

guard vets every hop before it connects: it raises FetchError to refuse the hop, or returns the IP addresses it vetted, which the connection is then pinned to (tried in order, so a second DNS answer can't swap in another address), or nil to connect normally.

Source
request_target(uri : URI) : String

The request line carries what a browser or curl would send: bytes outside printable ASCII (raw UTF-8, spaces) are percent-encoded, existing %XX escapes and reserved characters stay as they are.

Source
sanitized_url(url : String) : String

Secrets travel in headers and (via ${VAR}) sometimes in the query string, so log lines and error messages carry only scheme://host[:port]/path — never headers, query, or userinfo.

Source

Nested types