lib/httpx/session.rb in httpx-1.1.2 vs lib/httpx/session.rb in httpx-1.1.3
- old
+ new
@@ -149,10 +149,20 @@
set_connection_callbacks(connection, connections, options)
end
connection
end
+ def send_request(request, connections, options = request.options)
+ error = catch(:resolve_error) do
+ connection = find_connection(request, connections, options)
+ connection.send(request)
+ end
+ return unless error.is_a?(Error)
+
+ request.emit(:response, ErrorResponse.new(request, error, options))
+ end
+
# sets the callbacks on the +connection+ required to process certain specific
# connection lifecycle events which deal with request rerouting.
def set_connection_callbacks(connection, connections, options)
connection.only(:misdirected) do |misdirected_request|
other_connection = connection.create_idle(ssl: { alpn_protocols: %w[http/1.1] })
@@ -279,16 +289,10 @@
# sends an array of HTTPX::Request objects
def _send_requests(requests)
connections = []
requests.each do |request|
- error = catch(:resolve_error) do
- connection = find_connection(request, connections, request.options)
- connection.send(request)
- end
- next unless error.is_a?(ResolveError)
-
- request.emit(:response, ErrorResponse.new(request, error, request.options))
+ send_request(request, connections)
end
connections
end