-
Notifications
You must be signed in to change notification settings - Fork 980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Faraday::Response - argument order causes unexpected behaviour #1498
Comments
Thank you for reporting this @opensourceame, I totally agree this is surprising! [19] pry(main)> Faraday::Response.new(status: 200, body: 'test')
=> #<Faraday::Response:0x0000000136195a78
@env=
#<struct Faraday::Env
method=nil,
request_body=nil,
url=nil,
request=nil,
request_headers=nil,
ssl=nil,
parallel_manager=nil,
params=nil,
response=nil,
response_headers=nil,
status=200,
reason_phrase=nil,
response_body="test">,
@on_complete_callbacks=[]>
[20] pry(main)>
[21] pry(main)> Faraday::Response.new(body: 'test', status: 200)
=> #<Faraday::Response:0x0000000116e26898
@env=
#<struct Faraday::Env
method=nil,
request_body="test",
url=nil,
request=nil,
request_headers=nil,
ssl=nil,
parallel_manager=nil,
params=nil,
response=nil,
response_headers=nil,
status=200,
reason_phrase=nil,
response_body=nil>,
@on_complete_callbacks=[]> Why is this happening?As you can see from above, When you generate the hashes in your examples, Is this expected?Although really convoluted, I'd say this is expected behaviour, because of the nature of the The real surprise here is that I'm currently planning some work on those |
Thanks for your response @iMacTia. I'm creating the response manually to create a dummy response when I get a callback from a remote server, which is passed to Ruby code via a queue system. Is there a better way to do this than initialising a response object, as in my example? Agreed that body should not be accepted as an init param. Looking forward to your improvements ;-) |
I don't have a good alternative to that to be honest, but if you use a |
Basic Info
Issue description
When creating a
Faraday::Response
the body of the response is nullified if the status argument is specified after the body. This very unexpected behaviour.Steps to reproduce
works as expected:
body is nullified:
The text was updated successfully, but these errors were encountered: