diff options
author | Andrew Kane <[email protected]> | 2023-11-09 15:24:39 -0800 |
---|---|---|
committer | git <[email protected]> | 2023-12-07 07:00:54 +0000 |
commit | 41c00bc97ebf237fd04ce740d0dfd0681f4a28c7 (patch) | |
tree | b083574be631f62055c5dc5de4020f72cf0301dc /lib | |
parent | d97479f9c966bd2c9d52c8be28aca9431760c610 (diff) |
[ruby/open-uri] Set default for max_redirects and add exception class
https://github.com/ruby/open-uri/commit/dcdcb885cc
Diffstat (limited to 'lib')
-rw-r--r-- | lib/open-uri.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/open-uri.rb b/lib/open-uri.rb index 56dac75b29..49488cfc8e 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -108,7 +108,7 @@ module OpenURI :ftp_active_mode => false, :redirect => true, :encoding => nil, - :max_redirects => nil, + :max_redirects => 64, } def OpenURI.check_options(options) # :nodoc: @@ -240,7 +240,7 @@ module OpenURI uri = redirect raise "HTTP redirection loop: #{uri}" if uri_set.include? uri.to_s uri_set[uri.to_s] = true - raise "Too many redirects" if max_redirects && uri_set.size > max_redirects + raise TooManyRedirects.new("Too many redirects", buf.io) if max_redirects && uri_set.size > max_redirects else break end @@ -395,6 +395,9 @@ module OpenURI attr_reader :uri end + class TooManyRedirects < HTTPError + end + class Buffer # :nodoc: all def initialize @io = StringIO.new |