Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

net http timeout can be a float #70

Merged
merged 1 commit into from

8 participants

@abdollar

net http timeout can be a float for finer grained timeouts - I needed this for supporting less than one second timeouts as one second is too long for us.

@bowsersenior

+1 for this functionality

@ricokareem

nice! we need this at AT&T. the EdgeCase guys came up with a workaround--but yours actually works!
Pull baby pull

@nhsu

+1.1

@dmcinnes

+1 !!

@fuentesjr

any word on when this will be pulled/merged?

@ravibhim

+1 . This is better than sliced bread.

@jnunemaker jnunemaker merged commit adb9553 into jnunemaker:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 17, 2011
  1. net http timeout can also be a float

    Abdul Chaudhry authored
This page is out of date. Refresh to see the latest.
View
2  lib/httparty.rb
@@ -152,7 +152,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
View
2  lib/httparty/request.rb
@@ -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
View
5 spec/httparty_spec.rb
@@ -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
Something went wrong with that request. Please try again.