promoting build_request to public API, thereby allowing users to create request objects and pass them on to #send

This commit is contained in:
HoneyryderChuck 2020-10-06 13:19:21 +01:00
parent 9f33518850
commit 978a5ffa22
2 changed files with 3 additions and 11 deletions

View File

@ -10,8 +10,8 @@ module HTTPX
MOD
end
def request(verb, uri, **options)
branch(default_options).request(verb, uri, **options)
def request(*args, **options)
branch(default_options).request(*args, **options)
end
# :nocov:

View File

@ -31,7 +31,7 @@ module HTTPX
end
def request(*args, **options)
requests = build_requests(*args, options)
requests = args.first.is_a?(Request) ? args : build_requests(*args, options)
responses = send_requests(*requests, options)
return responses.first if responses.size == 1
@ -205,14 +205,6 @@ module HTTPX
end
end
def build_request(verb, uri, options)
rklass = @options.request_class
request = rklass.new(verb, uri, @options.merge(options).merge(persistent: @persistent))
request.on(:response, &method(:on_response).curry[request])
request.on(:promise, &method(:on_promise))
request
end
@default_options = Options.new
@default_options.freeze
@plugins = []