lib/httpx/adapters/faraday.rb in httpx-0.18.7 vs lib/httpx/adapters/faraday.rb in httpx-0.19.0
- old
+ new
@@ -79,10 +79,13 @@
module RequestMethods
attr_writer :response_on_data
def response=(response)
super
+
+ return if response.is_a?(::HTTPX::ErrorResponse)
+
response.body.on_data = @response_on_data
end
end
module ResponseBodyMethods
@@ -134,11 +137,11 @@
super
end
def on_response(&blk)
if blk
- @on_response = lambda do |response|
+ @on_response = ->(response) do
blk.call(response)
end
self
else
@on_response
@@ -198,19 +201,20 @@
def setup_parallel_manager
ParallelManager.new
end
end
- def initialize(app)
+ def initialize(app, options = {})
super(app)
- @session = Session.new
+ @session = Session.new(options)
end
def call(env)
super
if parallel?(env)
handler = env[:parallel_manager].enqueue(env)
handler.on_response do |response|
+ response.raise_for_status
save_response(env, response.status, response.body.to_s, response.headers, response.reason) do |response_headers|
response_headers.merge!(response.headers)
end
end
return handler