Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix redirect limited(0) should not follow redirects #1645

Merged
merged 4 commits into from Oct 10, 2022

Conversation

phankydn
Copy link
Contributor

@phankydn phankydn commented Oct 7, 2022

Fixed #1639

@phankydn phankydn 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
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