diff options
| author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-09 03:15:14 +0000 |
|---|---|---|
| committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-09 03:15:14 +0000 |
| commit | 21f7aa68f2d06e6ba1d2fedcfa63495b7c96326f (patch) | |
| tree | 11dbaa4deadbdb5e5e9781cb35de157fe152c84f /lib | |
| parent | b503b7b45bb20760b8474d4be2074239fda46e07 (diff) | |
r22137@crimson: knu | 2009-02-08 21:40:10 +0900
* add :read_timeout option. [ruby-core:4848] (r9166)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@22148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/open-uri.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/open-uri.rb b/lib/open-uri.rb index 54b42f336f..f54f6f2b41 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -94,6 +94,7 @@ module OpenURI :progress_proc => true, :content_length_proc => true, :http_basic_authentication => true, + :read_timeout => true, } def OpenURI.check_options(options) # :nodoc: @@ -234,6 +235,9 @@ module OpenURI store.set_default_paths http.cert_store = store end + if options.include? :read_timeout + http.read_timeout = options[:read_timeout] + end header = {} options.each {|k, v| header[k] = v if String === k } @@ -511,6 +515,13 @@ module OpenURI # pbar.set s if pbar # }) {|f| ... } # + # [:read_timeout] + # Synopsis: + # :read_timeout=>nil (no timeout) + # :read_timeout=>10 (10 second) + # + # :read_timeout option specifies a timeout of read for http connections. + # # OpenURI::OpenRead#open returns an IO like object if block is not given. # Otherwise it yields the IO object and return the value of the block. # The IO object is extended with OpenURI::Meta. |
