Skip to main content

get_validated

Function get_validated 

Source
pub fn get_validated(
    url: &str,
    accept: Option<&str>,
) -> Result<Response<Body>, String>
Expand description

Perform a GET, following redirects manually with the allowlist re-applied at every hop.

The URL the caller passes is validated before the first request, and each Location is resolved and validated before the next one. A redirect to a host outside ALLOWED_DOWNLOAD_HOSTS, a redirect with no Location, and a chain longer than [MAX_REDIRECTS] are all hard errors — none of them fall through to reading a body. A 3xx body is never read.

§Errors

Returns an error if the URL or any redirect target fails allowlist validation, if the request fails (DNS, connection, TLS), if a redirect carries no usable Location, or if the chain exceeds [MAX_REDIRECTS].