moved window size to options, changed it to 16K

This commit is contained in:
HoneyryderChuck 2017-12-10 20:37:27 +00:00
parent feac489f33
commit 94cb9b63d9
3 changed files with 8 additions and 2 deletions

View File

@ -12,8 +12,6 @@ module HTTPX
"http/1.1" => HTTP1
}
BUFFER_SIZE = 1 << 16
class << self
def by(uri, options, &blk)
io = case uri.scheme
@ -31,6 +29,7 @@ module HTTPX
def initialize(io, options, &on_response)
@io = io
@options = Options.new(options)
@window_size = @options.window_size
@read_buffer = +""
@write_buffer = +""
@pending = []

View File

@ -4,6 +4,7 @@ module HTTPX
class Options
MAX_CONCURRENT_REQUESTS = 100
MAX_RETRIES = 3
WINDOW_SIZE = 1 << 14
class << self
def inherited(klass)
@ -46,6 +47,7 @@ module HTTPX
:cookies => {},
:max_concurrent_requests => MAX_CONCURRENT_REQUESTS,
:max_retries => MAX_RETRIES,
:window_size => WINDOW_SIZE,
:request_class => Class.new(Request),
:response_class => Class.new(Response),
:headers_class => Class.new(Headers),
@ -77,6 +79,10 @@ module HTTPX
self.max_concurrent_requests = max
end
def_option(:window_size) do |num|
self.window_size = Integer(num)
end
%w[
params form json body
proxy follow ssl max_retries

View File

@ -62,6 +62,7 @@ class OptionsSpec < Minitest::Test
:json => nil,
:body => nil,
:follow => nil,
:window_size => 16_384,
:form => {:bar => "bar"},
:timeout => Timeout::PerOperation.new,
:ssl => {:foo => "bar"},