Skip to content

Conversation

@basicn86
Copy link
Contributor

@basicn86 basicn86 commented Jul 6, 2023

So I am building a web scraper and I noticed sometimes it will follow a long set of redirects, probably from a scam website or something. But I looked at the documentation and the maximum redirects that HttpWebRequest and HttpClientHandler will follow is 50 by default. I think this is too much so I added the ability to adjust the maximum number of redirects that will be followed. This is so I can save on bandwidth and compute power.

When the redirect limit is hit, HtmlWeb.StatusCode will be a 3xx status code. If the resource is reached before the redirect limit, then it will be a 2xx status code.

HttpWebRequest.MaximumAutomaticRedirections Property

HttpClientHandler.MaxAutomaticRedirections Property

@JonathanMagnan JonathanMagnan self-assigned this Jul 7, 2023
@JonathanMagnan
Copy link
Member

Thank you for your pull request. We will review it soon.

@JonathanMagnan JonathanMagnan merged commit e4e5121 into zzzprojects:master Jul 19, 2023
@JonathanMagnan
Copy link
Member

Hello @basicn86

Thank you again for your contribution.

Your code is available in the v1.11.50, the only change we made is instead to hardcode the value 50, we set it nullable with the logic to handle it. My developer was more comfortable this way as we never know if in a future version, if the value will be modified (could be debatable here). Have a great week ;)

Best Regards,

Jon

@basicn86
Copy link
Contributor Author

Thanks! That's understandable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants