lib/patron/request.rb in patron-0.12.1 vs lib/patron/request.rb in patron-0.13.1
- old
+ new
@@ -86,29 +86,31 @@
raise ArgumentError, "Action must be one of #{VALID_ACTIONS.join(', ')}"
end
@action = action.downcase.to_sym
end
- # Sets the read timeout for the CURL request, in seconds
+ # Sets the read timeout for the CURL request, in seconds.
+ # Can be set to less than a second using a floating-point value.
+ # Setting the value to 0 will disable the timeout.
#
# @param new_timeout[Integer] the number of seconds to wait before raising a timeout error
def timeout=(new_timeout)
- if new_timeout && new_timeout.to_i < 1
- raise ArgumentError, "Timeout must be a positive integer greater than 0"
+ if new_timeout && new_timeout.to_f < 0
+ raise ArgumentError, "Timeout must be a positive number"
end
-
- @timeout = new_timeout.to_i
+ @timeout = new_timeout.to_f
end
# Sets the connect timeout for the CURL request, in seconds.
+ # Can be set to less than a second using a floating-point value.
#
# @param new_timeout[Integer] the number of seconds to wait before raising a timeout error
def connect_timeout=(new_timeout)
- if new_timeout && new_timeout.to_i < 1
- raise ArgumentError, "Timeout must be a positive integer greater than 0"
+ if new_timeout && new_timeout.to_f < 0
+ raise ArgumentError, "Timeout must be a positive number"
end
- @connect_timeout = new_timeout.to_i
+ @connect_timeout = new_timeout.to_f
end
# Sets the maximum number of redirects that are going to be followed.
#
# @param new_max_redirects[Integer] The number of redirects to follow, or `-1` for unlimited redirects.