mirror of
https://github.com/jnunemaker/httparty
synced 2023-03-27 23:23:07 -04:00
net http timeout can also be a float
This commit is contained in:
parent
00a7ec9ce5
commit
c1ea5fc212
3 changed files with 7 additions and 2 deletions
|
@ -152,7 +152,7 @@ module HTTParty
|
|||
# default_timeout 10
|
||||
# end
|
||||
def default_timeout(t)
|
||||
raise ArgumentError, 'Timeout must be an integer' unless t && t.is_a?(Integer)
|
||||
raise ArgumentError, 'Timeout must be an integer or float' unless t && (t.is_a?(Integer) || t.is_a?(Float))
|
||||
default_options[:timeout] = t
|
||||
end
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ module HTTParty
|
|||
http = Net::HTTP.new(uri.host, uri.port, options[:http_proxyaddr], options[:http_proxyport])
|
||||
http.use_ssl = ssl_implied?
|
||||
|
||||
if options[:timeout] && options[:timeout].is_a?(Integer)
|
||||
if options[:timeout] && (options[:timeout].is_a?(Integer) || options[:timeout].is_a?(Float))
|
||||
http.open_timeout = options[:timeout]
|
||||
http.read_timeout = options[:timeout]
|
||||
end
|
||||
|
|
|
@ -232,6 +232,11 @@ describe HTTParty do
|
|||
@klass.default_timeout 10
|
||||
@klass.default_options[:timeout].should == 10
|
||||
end
|
||||
|
||||
it "should support floats" do
|
||||
@klass.default_timeout 0.5
|
||||
@klass.default_options[:timeout].should == 0.5
|
||||
end
|
||||
end
|
||||
|
||||
describe "debug_output" do
|
||||
|
|
Loading…
Add table
Reference in a new issue