mirror of
https://github.com/rust-unofficial/awesome-rust
synced 2024-11-15 16:37:57 +00:00
Add extra debug on redirects
This commit is contained in:
parent
39b2e4b3b6
commit
fd843a5dd8
1 changed files with 8 additions and 3 deletions
11
src/main.rs
11
src/main.rs
|
@ -81,9 +81,14 @@ async fn get_url(url: String) -> (String, Result<String>) {
|
|||
continue;
|
||||
}
|
||||
Ok(ref ok) => {
|
||||
if ok.status() != StatusCode::OK {
|
||||
warn!("Error while getting {}, retrying: {}", url, ok.status());
|
||||
res = Err(anyhow::anyhow!("Got status code {}", ok.status()));
|
||||
let status = ok.status();
|
||||
if status != StatusCode::OK {
|
||||
warn!("Error while getting {}, retrying: {}", url, status);
|
||||
if status.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));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue