http
http copied to clipboard
Add on_redirect callback.
Hello,
This adds an on_redirect callback that can be passed to .follow. For example:
permanent_redirects = []
HTTP.follow(
max_hops: 4,
on_redirect: proc do |from, to|
permanent_redirects.push({ from: from.uri.to_s, to: to.uri.to_s }) if [301, 308].include?(from.status.code)
end
).get("…")
I found this feature to be useful while trying to come up with a redirect caching system.
Thanks!