Project

General

Profile

Feature #10361 ยป diff.txt

kirs (Kir Shatrov), 10/10/2014 09:46 AM

 
diff --git a/lib/open-uri.rb b/lib/open-uri.rb
index b793828..829759a 100644
--- a/lib/open-uri.rb
+++ b/lib/open-uri.rb
@@ -102,6 +102,7 @@ module OpenURI
:content_length_proc => true,
:http_basic_authentication => true,
:read_timeout => true,
+ :open_timeout => true,
:ssl_ca_cert => nil,
:ssl_verify_mode => nil,
:ftp_active_mode => false,
@@ -307,6 +308,9 @@ module OpenURI
if options.include? :read_timeout
http.read_timeout = options[:read_timeout]
end
+ if options.include? :open_timeout
+ http.open_timeout = options[:open_timeout]
+ end
resp = nil
http.start {
@@ -667,6 +671,13 @@ module OpenURI
#
# :read_timeout option specifies a timeout of read for http connections.
#
+ # [:open_timeout]
+ # Synopsis:
+ # :open_timeout=>nil (no timeout)
+ # :open_timeout=>10 (10 second)
+ #
+ # :open_timeout option specifies a timeout of open for http connections.
+ #
# [:ssl_ca_cert]
# Synopsis:
# :ssl_ca_cert=>filename
    (1-1/1)