letmutres=Err(anyhow::anyhow!("Should always try at least once.."));
for_in0..5u8{
debug!("Running {}",url);
letresp=CLIENT
.get(&url)
.header(header::ACCEPT,"text/html, */*;q=0.8")
.send()
.await;
matchresp{
Err(err)=>{
warn!("Error while getting {}, retrying: {}",url,err);
continue;
}
Ok(refok)=>{
letstatus=ok.status();
ifstatus!=StatusCode::OK{
warn!("Error while getting {}, retrying: {}",url,status);
ifstatus.is_redirection(){
res=Err(anyhow::anyhow!("Got status code {} redirecting to {}",status,ok.headers().get(header::LOCATION).and_then(|h|h.to_str().ok()).unwrap_or("<unknown>")));
}else{
res=Err(anyhow::anyhow!("Got status code {}",status));
warn!("Error while getting {}, retrying: {}",url,status);
ifstatus.is_redirection(){
res=Err(anyhow::anyhow!("Got status code {} redirecting to {}",status,ok.headers().get(header::LOCATION).and_then(|h|h.to_str().ok()).unwrap_or("<unknown>")));
}else{
res=Err(anyhow::anyhow!("Got status code {}",status));