lib/httpx/options.rb in httpx-0.22.5 vs lib/httpx/options.rb in httpx-0.23.0
- old
+ new
@@ -2,10 +2,11 @@
require "socket"
module HTTPX
class Options
+ BUFFER_SIZE = 1 << 14
WINDOW_SIZE = 1 << 14 # 16K
MAX_BODY_THRESHOLD_SIZE = (1 << 10) * 112 # 112K
CONNECT_TIMEOUT = 60
OPERATION_TIMEOUT = 60
KEEP_ALIVE_TIMEOUT = 20
@@ -39,10 +40,11 @@
write_timeout: WRITE_TIMEOUT,
request_timeout: REQUEST_TIMEOUT,
},
:headers => {},
:window_size => WINDOW_SIZE,
+ :buffer_size => BUFFER_SIZE,
:body_threshold_size => MAX_BODY_THRESHOLD_SIZE,
:request_class => Class.new(Request),
:response_class => Class.new(Response),
:headers_class => Class.new(Headers),
:request_body_class => Class.new(Request::Body),
@@ -176,19 +178,31 @@
value
end
def option_window_size(value)
- Integer(value)
+ value = Integer(value)
+
+ raise TypeError, ":window_size must be positive" unless value.positive?
+
+ value
end
+ def option_buffer_size(value)
+ value = Integer(value)
+
+ raise TypeError, ":buffer_size must be positive" unless value.positive?
+
+ value
+ end
+
def option_body_threshold_size(value)
Integer(value)
end
def option_transport(value)
transport = value.to_s
- raise TypeError, "\#{transport} is an unsupported transport type" unless IO.registry.key?(transport)
+ raise TypeError, "#{transport} is an unsupported transport type" unless %w[unix].include?(transport)
transport
end
def option_addresses(value)