mirror of
https://github.com/lostisland/faraday.git
synced 2025-10-04 00:02:03 -04:00
Fix response not changing with parallel requests
In this order the @env would not be changed by the "on complete" callbacks, meaning that the response would not change after parallel requests finish (e.g. JSON would not be parsed). This would work def on_complete(env) env[:body].upcase! end But this wouldn't def on_complete(env) env[:body] = env[:body].upcase end
This commit is contained in:
parent
3dc615a72e
commit
edacd5eb57
@ -61,8 +61,8 @@ module Faraday
|
||||
|
||||
def finish(env)
|
||||
raise "response already finished" if finished?
|
||||
@env = Env.from(env)
|
||||
@on_complete_callbacks.each { |callback| callback.call(env) }
|
||||
@env = Env.from(env)
|
||||
return self
|
||||
end
|
||||
|
||||
|
@ -166,6 +166,14 @@ class ResponseTest < Faraday::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_body_is_parsed_on_finish
|
||||
response = Faraday::Response.new
|
||||
response.on_complete { |env| env[:body] = env[:body].upcase }
|
||||
response.finish(@env)
|
||||
|
||||
assert_equal "YIKES", response.body
|
||||
end
|
||||
|
||||
def test_not_success
|
||||
assert !@response.success?
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user