From 5e7d8841afb66c6c4ee9ba4110d8dd61836f95c4 Mon Sep 17 00:00:00 2001 From: James Wykeham-Martin Date: Fri, 2 Feb 2018 09:58:09 +0000 Subject: [PATCH] Added loopback detection using current last rather than contains --- hammond-downloader/src/downloader.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hammond-downloader/src/downloader.rs b/hammond-downloader/src/downloader.rs index cf614fc..2176922 100644 --- a/hammond-downloader/src/downloader.rs +++ b/hammond-downloader/src/downloader.rs @@ -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() }