Skip to content

Conversation

anhcuky
Copy link
Contributor

@anhcuky anhcuky commented Oct 7, 2022

Fixed #1639

@anhcuky anhcuky changed the title Fix redirect limited(0) should not follows redirects Fix redirect limited(0) should not follow redirects Oct 7, 2022
@@ -128,7 +128,7 @@ impl Policy {
match self.inner {
PolicyKind::Custom(ref custom) => custom(attempt),
PolicyKind::Limit(max) => {
if attempt.previous.len() == max {
if attempt.previous.len() >= max {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this still be without the change? The previous length should be 0, and max is 0... Is there a time that isn't true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.as_mut().urls().push(url);

Yes, it isn't true because the url is pushed to the previousbefore calling check, so the length always has at least 1 item.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, of course! Want to readd the test but with a URL in the previous Vec as well, so we catch this if it ever changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the test.

Copy link
Owner

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for catching this!

@seanmonstar seanmonstar merged commit 110c3ae into seanmonstar:master Oct 10, 2022
Nutomic pushed a commit to Nutomic/reqwest that referenced this pull request Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reqwest::redirect::Policy::limited(0) still follows redirects
2 participants