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.
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.