mirror of
https://github.com/rust-unofficial/awesome-rust
synced 2024-11-04 12:00:12 +00:00
Ignore temporary redirects
This commit is contained in:
parent
bf52c2c1d4
commit
adbe935fc5
13
src/main.rs
13
src/main.rs
@ -324,11 +324,14 @@ fn get_url_core(url: String) -> BoxFuture<'static, (String, Result<(), CheckerEr
|
||||
return (url, Err(CheckerError::TooManyRequests));
|
||||
}
|
||||
|
||||
warn!("Error while getting {}, retrying: {}", url, status);
|
||||
if status.is_redirection() {
|
||||
res = Err(CheckerError::HttpError {status: status.as_u16(), location: ok.headers().get(header::LOCATION).and_then(|h| h.to_str().ok()).map(|x| x.to_string())});
|
||||
break;
|
||||
if status != StatusCode::TEMPORARY_REDIRECT && status != StatusCode::FOUND { // ignore temporary redirects
|
||||
res = Err(CheckerError::HttpError {status: status.as_u16(), location: ok.headers().get(header::LOCATION).and_then(|h| h.to_str().ok()).map(|x| x.to_string())});
|
||||
warn!("Redirect while getting {} - {}", url, status);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
warn!("Error while getting {}, retrying: {}", url, status);
|
||||
res = Err(CheckerError::HttpError {status: status.as_u16(), location: None});
|
||||
continue;
|
||||
}
|
||||
@ -711,9 +714,7 @@ async fn main() -> Result<(), Error> {
|
||||
for (url, link) in results.iter() {
|
||||
if let Working::No(ref err) = link.working {
|
||||
match err {
|
||||
CheckerError::HttpError { status, .. }
|
||||
if *status == 301 || *status == 302 || *status == 404 =>
|
||||
{
|
||||
CheckerError::HttpError { status, .. } if *status == 301 || *status == 404 => {
|
||||
println!("{} {:?}", url, link);
|
||||
failed += 1;
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user