mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-26 03:26:19 +00:00
no unwrappear al crear request
crashea en urls invalidas
This commit is contained in:
parent
80462d02bb
commit
7806c0ba6f
1 changed files with 6 additions and 4 deletions
|
@ -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() {
|
||||||
|
|
Loading…
Reference in a new issue