INNER CODE UNIT · Rust
redirect
hatoo/oha · src/client.rs:922
async fn redirect<R: Rng + Send + Copy>(
&self,
base_url: Cow<'_, Url>,
seed: R,
send_request: SendRequestHttp1,
location: &http::header::HeaderValue,
limit: usize,
rng: &mut R,
) -> Result<(SendRequestHttp1, http::StatusCode, usize), ClientError> {
if limit == 0 {
return Err(ClientError::TooManyRedirect);
}
let url = match Url::parse(location.to_str()?) {
Ok(url) => url,
Err(ParseError::RelativeUrlWithoutBase) => Url::options()
.base_url(Some(&base_url))
.parse(location.to_str()?)?,
Err(err) => Err(err)?,