diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-09-15 04:56:25 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-09-15 04:56:25 +0000 |
| commit | 41628b094c47d7992890f75d4e4637bdb198a971 (patch) | |
| tree | e0489459af551814f54fcd2ef5c5a4208eda82c5 /lib/open-uri.rb | |
| parent | e60615406d7981e80f378761d392e5aa998a589a (diff) | |
| download | ruby-41628b094c47d7992890f75d4e4637bdb198a971.tar.gz ruby-41628b094c47d7992890f75d4e4637bdb198a971.tar.xz ruby-41628b094c47d7992890f75d4e4637bdb198a971.zip | |
* lib/open-uri.rb: add :read_timeout option.
[ruby-core:4848]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@9166 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/open-uri.rb')
| -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 ce6058935..9220148d9 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -97,6 +97,7 @@ module OpenURI :progress_proc => true, :content_length_proc => true, :http_basic_authentication => true, + :read_timeout => true, } def OpenURI.check_options(options) # :nodoc: @@ -237,6 +238,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 } @@ -524,6 +528,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. |
