riboseinc / uri_format_validator

Validate URL for Rails
MIT License
3 stars 2 forks source link

When validating retrievability, it should follow redirections #58

Open skalee opened 6 years ago

skalee commented 6 years ago

In case of HTTP 301 or 302, the validator should perform another request to ensure that location pointed out in the redirection response is indeed retrievable.

ronaldtse commented 6 years ago

Agree. Not sure if we want to allow 301/302 independently or require the redirected result to be retrievable? Maybe we can allow the user to specify what status codes are acceptable (2xx, 3xx, 4xx)?

skalee commented 6 years ago

IMHO the latter, we should follow redirections (up to about 10 hops) and ensure that redirections chain ends with some 2xx response.

ronaldtse commented 6 years ago

There is a possible issue if someone enters a never ending redirection, then it would max out the hops and use up considerable resources...

Maybe the user can specify an accepted end status, such as if "acceptable: [300..399]" is acceptable we don't even check the redirection. But if user configures "follow_redirects: 5" then we go with 5 hops max until we hit an acceptable state or reach max hops?