-
Notifications
You must be signed in to change notification settings - Fork 326
Open
Labels
Description
Hi, love httprb.
I would like to suggest to add some validation of the arguments to timeout. I can see that there are already some but we managed to pass {timeout: 5}
as the argument
This is the related code.
Lines 93 to 112 in 462d711
def timeout(options) | |
klass, options = case options | |
when Numeric then [HTTP::Timeout::Global, {:global => options}] | |
when Hash then [HTTP::Timeout::PerOperation, options.dup] | |
when :null then [HTTP::Timeout::Null, {}] | |
else raise ArgumentError, "Use `.timeout(global_timeout_in_seconds)` or `.timeout(connect: x, write: y, read: z)`." | |
end | |
%i[global read write connect].each do |k| | |
next unless options.key? k | |
options["#{k}_timeout".to_sym] = options.delete k | |
end | |
branch default_options.merge( | |
:timeout_class => klass, | |
:timeout_options => options | |
) | |
end |
I can open a PR of you would want that?
ixti