mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
promoting build_request to public API, thereby allowing users to create request objects and pass them on to #send
This commit is contained in:
parent
9f33518850
commit
978a5ffa22
@ -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:
|
||||
|
@ -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 = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user