@@ -39,14 +39,14 @@ def client_for(endpoint)
39
39
# @parameter url [String] The URL to request, e.g. `https://www.codeotaku.com`.
40
40
# @parameter headers [Hash | Protocol::HTTP::Headers] The headers to send with the request.
41
41
# @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 )
43
43
endpoint = Endpoint [ url ]
44
44
client = self . client_for ( endpoint )
45
45
46
- body = Body :: Buffered . wrap ( body )
47
- headers = :: Protocol :: HTTP :: Headers [ headers ]
46
+ options [ :authority ] ||= endpoint . authority
47
+ options [ :scheme ] ||= endpoint . scheme
48
48
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 ]
50
50
51
51
response = client . call ( request )
52
52
@@ -68,8 +68,8 @@ def close
68
68
end
69
69
70
70
::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 )
73
73
end
74
74
end
75
75
0 commit comments