Skip to main content

validate_url

Function validate_url 

Source
pub fn validate_url(url: &Url, allow: &[IpNet]) -> Result<(), RequestError>
Expand description

Check a URL before requesting it: its scheme, and its host when the host is a literal address, which DNS never sees.

Every request Client sends is checked with this first, and a name is checked on the addresses it resolves to when the connection is made; an application that sends a request some other way, or wants to refuse a URL before it gets that far, checks it here against the same allow list.

ยงErrors

RequestError::InvalidUrl when the URL is not http or https with a host, and RequestError::Refused when its host is an address neither public nor in allow.