mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
http2: added http2_settings as configurable options; allow parser to be upgraded
This commit is contained in:
parent
30fcdfeb2c
commit
0dc0003333
@ -115,6 +115,11 @@ module HTTPX
|
||||
nil
|
||||
end
|
||||
|
||||
def upgrade_parser(protocol)
|
||||
@parser.close if @parser
|
||||
@parser = build_parser(protocol)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def connect
|
||||
@ -151,12 +156,14 @@ module HTTPX
|
||||
end
|
||||
|
||||
def parser
|
||||
@parser || begin
|
||||
@parser = registry(@io.protocol).new(@write_buffer, @options)
|
||||
@parser.on(:response, &@on_response)
|
||||
@parser.on(:close) { throw(:close, self) }
|
||||
@parser
|
||||
end
|
||||
@parser ||= build_parser
|
||||
end
|
||||
|
||||
def build_parser(protocol=@io.protocol)
|
||||
parser = registry(protocol).new(@write_buffer, @options)
|
||||
parser.on(:response, &@on_response)
|
||||
parser.on(:close) { throw(:close, self) }
|
||||
parser
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -202,6 +202,14 @@ module HTTPX
|
||||
stream.refuse
|
||||
# TODO: policy for handling promises
|
||||
end
|
||||
|
||||
def method_missing(meth, *args, &blk)
|
||||
if @connection.respond_to?(meth)
|
||||
@connection.__send__(meth, *args, &blk)
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
Channel.register "h2", Channel::HTTP2
|
||||
end
|
||||
|
@ -42,6 +42,7 @@ module HTTPX
|
||||
:debug => ENV.key?("HTTPX_DEBUG") ? $stderr : nil,
|
||||
:debug_level => (ENV["HTTPX_DEBUG"] || 1).to_i,
|
||||
:ssl => { alpn_protocols: %w[h2 http/1.1] },
|
||||
:http2_settings => { settings_enable_push: 0 },
|
||||
:fallback_protocol => "http/1.1",
|
||||
:timeout => Timeout.by(:per_operation),
|
||||
:headers => {},
|
||||
@ -84,7 +85,7 @@ module HTTPX
|
||||
|
||||
%w[
|
||||
params form json body
|
||||
follow ssl max_retries
|
||||
follow ssl http2_settings max_retries
|
||||
request_class response_class headers_class response_body_class
|
||||
io fallback_protocol debug debug_level
|
||||
].each do |method_name|
|
||||
@ -97,9 +98,7 @@ module HTTPX
|
||||
|
||||
merged = h1.merge(h2) do |k, v1, v2|
|
||||
case k
|
||||
when :headers
|
||||
v1.merge(v2)
|
||||
when :ssl
|
||||
when :headers, :ssl, :http2_settings
|
||||
v1.merge(v2)
|
||||
else
|
||||
v2
|
||||
|
Loading…
x
Reference in New Issue
Block a user