mirror of
https://github.com/rust-unofficial/awesome-rust
synced 2025-02-16 20:28:25 +00:00
Ignore temporary redirects
This commit is contained in:
parent
bf52c2c1d4
commit
adbe935fc5
1 changed files with 7 additions and 6 deletions
|
@ -324,11 +324,14 @@ fn get_url_core(url: String) -> BoxFuture<'static, (String, Result<(), CheckerEr
|
||||||
return (url, Err(CheckerError::TooManyRequests));
|
return (url, Err(CheckerError::TooManyRequests));
|
||||||
}
|
}
|
||||||
|
|
||||||
warn!("Error while getting {}, retrying: {}", url, status);
|
|
||||||
if status.is_redirection() {
|
if status.is_redirection() {
|
||||||
|
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())});
|
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;
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
warn!("Error while getting {}, retrying: {}", url, status);
|
||||||
res = Err(CheckerError::HttpError {status: status.as_u16(), location: None});
|
res = Err(CheckerError::HttpError {status: status.as_u16(), location: None});
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -711,9 +714,7 @@ async fn main() -> Result<(), Error> {
|
||||||
for (url, link) in results.iter() {
|
for (url, link) in results.iter() {
|
||||||
if let Working::No(ref err) = link.working {
|
if let Working::No(ref err) = link.working {
|
||||||
match err {
|
match err {
|
||||||
CheckerError::HttpError { status, .. }
|
CheckerError::HttpError { status, .. } if *status == 301 || *status == 404 => {
|
||||||
if *status == 301 || *status == 302 || *status == 404 =>
|
|
||||||
{
|
|
||||||
println!("{} {:?}", url, link);
|
println!("{} {:?}", url, link);
|
||||||
failed += 1;
|
failed += 1;
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue