Skip to content

Commit f3e6a36

Browse files
committed
Update Internet to accept keyword arguments.
1 parent 3eb6983 commit f3e6a36

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/async/http/internet.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ def client_for(endpoint)
3939
# @parameter url [String] The URL to request, e.g. `https://www.codeotaku.com`.
4040
# @parameter headers [Hash | Protocol::HTTP::Headers] The headers to send with the request.
4141
# @parameter body [String | Protocol::HTTP::Body] The body to send with the request.
42-
def call(method, url, headers = nil, body = nil, &block)
42+
def call(verb, url, *arguments, **options, &block)
4343
endpoint = Endpoint[url]
4444
client = self.client_for(endpoint)
4545

46-
body = Body::Buffered.wrap(body)
47-
headers = ::Protocol::HTTP::Headers[headers]
46+
options[:authority] ||= endpoint.authority
47+
options[:scheme] ||= endpoint.scheme
4848

49-
request = ::Protocol::HTTP::Request.new(endpoint.scheme, endpoint.authority, method, endpoint.path, nil, headers, body)
49+
request = ::Protocol::HTTP::Request[verb, endpoint.path, *arguments, **options]
5050

5151
response = client.call(request)
5252

@@ -68,8 +68,8 @@ def close
6868
end
6969

7070
::Protocol::HTTP::Methods.each do |name, verb|
71-
define_method(verb.downcase) do |url, headers = nil, body = nil, &block|
72-
self.call(verb, url, headers, body, &block)
71+
define_method(verb.downcase) do |url, *arguments, **options, &block|
72+
self.call(verb, url, *arguments, **options, &block)
7373
end
7474
end
7575

0 commit comments

Comments
 (0)