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