lib/httpx/session.rb in httpx-0.6.2 vs lib/httpx/session.rb in httpx-0.6.3
- old
+ new
@@ -91,19 +91,16 @@
# get uninitialized requests
# incidentally, all requests will be re-routed to the first
# advertised alt-svc, which incidentally follows the spec.
existing_connection.purge_pending do |request|
- is_idle = request.origin == origin &&
- request.state == :idle &&
- !request.headers.key?("alt-used")
- if is_idle
- log(level: 1) { "#{origin} alt-svc: sending #{request.uri} to #{alt_origin}" }
- connection.send(request)
- end
- is_idle
+ request.origin == origin &&
+ request.state == :idle &&
+ !request.headers.key?("alt-used")
end
+
+ connection.merge(existing_connection)
rescue UnsupportedSchemeError
altsvc["noop"] = true
end
def build_requests(*args, options)
@@ -135,21 +132,20 @@
def build_connection(uri, options)
type = options.transport || begin
case uri.scheme
when "http"
"tcp"
- when "https"
+ when "https", "h2"
"ssl"
- when "h2"
- options = options.merge(ssl: { alpn_protocols: %w[h2] })
- "ssl"
else
raise UnsupportedSchemeError, "#{uri}: #{uri.scheme}: unsupported URI scheme"
end
end
connection = options.connection_class.new(type, uri, options)
- pool.init_connection(connection, options)
- connection
+ catch(:coalesced) do
+ pool.init_connection(connection, options)
+ connection
+ end
end
def send_requests(*requests, options)
connections = []
request_options = @options.merge(options)