Skip to content

Commit

Permalink
Merge pull request #70 from abdollar/master
Browse files Browse the repository at this point in the history
net http timeout can be a float
  • Loading branch information
jnunemaker committed Jun 6, 2011
2 parents 2d4c1bd + c1ea5fc commit adb9553
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/httparty.rb
Expand Up @@ -148,7 +148,7 @@ def default_params(h={})
# 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

Expand Down
2 changes: 1 addition & 1 deletion lib/httparty/request.rb
Expand Up @@ -101,7 +101,7 @@ def http
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
Expand Down
5 changes: 5 additions & 0 deletions spec/httparty_spec.rb
Expand Up @@ -232,6 +232,11 @@ def second_method
@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
Expand Down

0 comments on commit adb9553

Please sign in to comment.