Skip to content
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

resp.join #1

Open
cj opened this issue May 22, 2014 · 4 comments
Open

resp.join #1

cj opened this issue May 22, 2014 · 4 comments

Comments

@cj
Copy link

cj commented May 22, 2014

'ello. I quick question, hopefully you can answer it as it's driving me nuts. I noticed you were doing this

resp.join.must.eq "user1"
resp.join when I try that in my own tests I get NoMethodError: undefined method 'join' for #<Rack::Response:0x00000002e63988> so end up having to do body = resp.send('body').join. Any idea on what I'm missing?

@mkristian
Copy link
Owner

I assume you are using cuba and/or cuba-api

cuba uses its own Cuba::Response class which is not Rack::Response - that might be the confusion. a call to Cuba.call will return [status, headers, body] where body is like an array of strings.

so I am not sure where the Rack::Response comes from. the Cuba.call will execute #finish on the Response (whatever Response class you are using) which returns the above array [status, headers, body].

if you give me more inside what you are doing I might be able to help further

@cj
Copy link
Author

cj commented May 23, 2014

@mkristian thank you for the response. I'm using Cuba, which is why I was confused I didn't get the same result as you. Here are the tests https://github.com/cj/cuba-tools/blob/master/test/tools/widget_test.rb

Thank you again!

@mkristian
Copy link
Owner

the Cuba::Tools::Widget::Responder uses Rack::Response which will be
returned. that one wraps the body in Rack::BodyProxy which basically
responds to :each which is needed to write out the response to client
socket.

Cuba usually uses Cuba::Response instead of Rack::Response which uses a
simple array as body.

so either you use Cuba::Response as well or at least
resp.send('body').join
to
resp.body.join

@cj
Copy link
Author

cj commented May 23, 2014

ah thank you, that makes perfect sense now. one other thing when passing in the @app https://github.com/cj/cuba-tools/blob/master/lib/cuba/tools/widget/responder.rb#L11 it seems to only have access to the last middleware and not the entire stack. Is there no way inside middleware to access the entire stack which has access to all the plugins etc..?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants