lib/httpx/options.rb in httpx-0.0.5 vs lib/httpx/options.rb in httpx-0.1.0
- old
+ new
@@ -1,11 +1,10 @@
# frozen_string_literal: true
module HTTPX
class Options
MAX_CONCURRENT_REQUESTS = 100
- MAX_RETRIES = 3
WINDOW_SIZE = 1 << 14 # 16K
MAX_BODY_THRESHOLD_SIZE = (1 << 10) * 112 # 112K
class << self
def inherited(klass)
@@ -45,18 +44,19 @@
:http2_settings => { settings_enable_push: 0 },
:fallback_protocol => "http/1.1",
:timeout => Timeout.new,
:headers => {},
:max_concurrent_requests => MAX_CONCURRENT_REQUESTS,
- :max_retries => MAX_RETRIES,
:window_size => WINDOW_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),
:response_body_class => Class.new(Response::Body),
+ :transport => nil,
+ :transport_options => nil,
}
defaults.merge!(options)
defaults[:headers] = Headers.new(defaults[:headers])
defaults.each { |(k, v)| self[k] = v }
@@ -82,14 +82,20 @@
def_option(:body_threshold_size) do |num|
self.body_threshold_size = Integer(num)
end
+ def_option(:transport) do |tr|
+ transport = tr.to_s
+ raise Error, "#{transport} is an unsupported transport type" unless IO.registry.keys.include?(transport)
+ self.transport = transport
+ end
+
%w[
params form json body
- follow ssl http2_settings max_retries
+ follow ssl http2_settings
request_class response_class headers_class request_body_class response_body_class
- io fallback_protocol debug debug_level
+ io fallback_protocol debug debug_level transport_options
].each do |method_name|
def_option(method_name)
end
def merge(other)