no unwrappear al crear request

crashea en urls invalidas
This commit is contained in:
Cat /dev/Nulo 2024-01-12 09:14:28 -03:00
parent 80462d02bb
commit 7806c0ba6f

View file

@ -139,6 +139,11 @@ enum FetchError {
Tl(#[from] tl::ParseError), Tl(#[from] tl::ParseError),
} }
async fn do_request(client: &reqwest::Client, url: &str) -> reqwest::Result<reqwest::Response> {
let request = client.get(url).build()?;
client.execute(request).await
}
#[tracing::instrument(skip(client))] #[tracing::instrument(skip(client))]
async fn fetch_and_parse( async fn fetch_and_parse(
client: &reqwest::Client, client: &reqwest::Client,
@ -149,10 +154,7 @@ async fn fetch_and_parse(
.with_jitter(true); .with_jitter(true);
let response = policy let response = policy
.retry(|| { .retry(|| do_request(client, &url))
let request = client.get(url.as_str()).build().unwrap();
client.execute(request)
})
.await .await
.map_err(FetchError::Http)?; .map_err(FetchError::Http)?;
if !response.status().is_success() { if !response.status().is_success() {