ssl options: passing alpn fixtures as ssl default options; this will allow disabling, and will centralize defaults

This commit is contained in:
HoneyryderChuck 2017-12-11 16:02:51 +00:00
parent 6220ecec15
commit 4e094f79d0
3 changed files with 4 additions and 6 deletions

View File

@ -101,10 +101,6 @@ module HTTPX
@negotiated = false
@ctx = OpenSSL::SSL::SSLContext.new
@ctx.set_params(options.ssl)
@ctx.alpn_protocols = %w[h2 http/1.1] if @ctx.respond_to?(:alpn_protocols=)
@ctx.alpn_select_cb = lambda do |pr|
pr.first unless pr.nil? || pr.empty?
end if @ctx.respond_to?(:alpn_select_cb=)
super
end

View File

@ -42,7 +42,7 @@ module HTTPX
def initialize(options = {})
defaults = {
:proxy => {},
:ssl => {},
:ssl => { alpn_protocols: %w[h2 http/1.1] },
:timeout => Timeout.by(:per_operation),
:headers => {},
:cookies => {},
@ -107,6 +107,8 @@ module HTTPX
case k
when :headers
v1.merge(v2)
when :ssl
v1.merge(v2)
else
v2
end

View File

@ -66,7 +66,7 @@ class OptionsSpec < Minitest::Test
:body_threshold_size => 114_688,
:form => {:bar => "bar"},
:timeout => Timeout::PerOperation.new,
:ssl => {:foo => "bar"},
:ssl => {:foo => "bar", :alpn_protocols => %w[h2 http/1.1] },
:headers => {"Foo" => "foo", "Accept" => "xml", "Bar" => "bar"},
:proxy => {:proxy_address => "127.0.0.1", :proxy_port => 8080},
:cookies => {},