mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
minimal changes to accomodate new kwargs syntax
This commit is contained in:
parent
4da021346e
commit
a421fb121b
@ -185,11 +185,11 @@ module Faraday
|
||||
return handler
|
||||
end
|
||||
|
||||
request_options = build_request(env)
|
||||
meth, uri, request_options = build_request(env)
|
||||
|
||||
session = @session.with(options_from_env(env))
|
||||
session = session.plugin(:proxy).with_proxy(proxy_options) if env.request.proxy
|
||||
response = session.__send__(*request_options)
|
||||
response = session.__send__(meth, uri, **request_options)
|
||||
response.raise_for_status unless response.is_a?(::HTTPX::Response)
|
||||
save_response(env, response.status, response.body.to_s, response.headers, response.reason) do |response_headers|
|
||||
response_headers.merge!(response.headers)
|
||||
|
@ -46,7 +46,7 @@ module HTTPX
|
||||
module ResponseBodyMethods
|
||||
attr_reader :encodings
|
||||
|
||||
def initialize(*)
|
||||
def initialize(*, **)
|
||||
@encodings = []
|
||||
|
||||
super
|
||||
|
@ -10,7 +10,7 @@ module HTTPX
|
||||
def self.new(opts = {})
|
||||
return opts if opts.is_a?(Timeout)
|
||||
|
||||
super
|
||||
super(**opts)
|
||||
end
|
||||
|
||||
attr_reader :connect_timeout, :operation_timeout, :total_timeout
|
||||
|
@ -34,8 +34,7 @@ class ResponseTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_response_body_to_s
|
||||
opts = { threshold_size: 1024 }
|
||||
body1 = Response::Body.new(Response.new(request, 200, "2.0", {}), opts)
|
||||
body1 = Response::Body.new(Response.new(request, 200, "2.0", {}), threshold_size: 1024)
|
||||
assert body1.empty?, "body must be empty after initialization"
|
||||
body1.write("foo")
|
||||
assert body1 == "foo", "body must be updated"
|
||||
@ -43,14 +42,13 @@ class ResponseTest < Minitest::Test
|
||||
body1.write("bar")
|
||||
assert body1 == "foobar", "body must buffer subsequent chunks"
|
||||
|
||||
body3 = Response::Body.new(Response.new(request("head"), 200, "2.0", {}), opts)
|
||||
body3 = Response::Body.new(Response.new(request("head"), 200, "2.0", {}), threshold_size: 1024)
|
||||
assert body3.empty?, "body must be empty after initialization"
|
||||
assert body3 == "", "HEAD requets body must be empty"
|
||||
end
|
||||
|
||||
def test_response_body_each
|
||||
opts = { threshold_size: 1024 }
|
||||
body1 = Response::Body.new(Response.new(request, 200, "2.0", {}), opts)
|
||||
body1 = Response::Body.new(Response.new(request, 200, "2.0", {}), threshold_size: 1024)
|
||||
body1.write("foo")
|
||||
assert body1.each.to_a == %w[foo], "must yield buffer"
|
||||
body1.write("foo")
|
||||
@ -59,8 +57,7 @@ class ResponseTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_response_body_buffer
|
||||
opts = { threshold_size: 10 }
|
||||
body = Response::Body.new(Response.new(request, 200, "2.0", {}), opts)
|
||||
body = Response::Body.new(Response.new(request, 200, "2.0", {}), threshold_size: 10)
|
||||
body.extend(Module.new do
|
||||
attr_reader :buffer
|
||||
end)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# testing proxies is a drag...
|
||||
module TestTimeoutDefaults
|
||||
def new(*)
|
||||
def new(**)
|
||||
timeout = super
|
||||
timeout.instance_variable_set(:@connect_timeout, 5)
|
||||
timeout
|
||||
|
Loading…
x
Reference in New Issue
Block a user