Added loopback detection using current last rather than contains

This commit is contained in:
James Wykeham-Martin 2018-02-02 09:58:09 +00:00
parent d0c5764471
commit 5e7d8841af

View File

@ -43,8 +43,10 @@ fn download_into(
// it has a loop back before giving correct url
let policy = RedirectPolicy::custom(|attempt| {
info!("Redirect Attempt URL: {:?}", attempt.url());
if attempt.previous().len() > 10 {
if attempt.previous().len() > 5 {
attempt.too_many_redirects()
} else if attempt.url() == attempt.previous().last().unwrap() {
attempt.loop_detected()
} else {
attempt.follow()
}