ncr / rack-proxy

A request/response rewriting HTTP proxy. A Rack app.
MIT License
269 stars 94 forks source link

When not streaming, body has no method `each` #23

Closed sinantaifour closed 10 years ago

sinantaifour commented 10 years ago

When I turn off streaming, any request results in:

ERROR NoMethodError: undefined method `each' for #<String:0x007f76f8bd7d58>

Replacing line 68 in lib/rack/proxy.rb with:

[target_response.code, headers, @streaming ? target_response.body : [target_response.body]]

Solves the problem, although it is far from an elegant solution.

ncr commented 10 years ago

This happens because the String#each method was removed in 1.9+.

sinantaifour commented 10 years ago

Just so I understand your reasoning, does this project not support Ruby 1.9+? If so, it might be a good idea to mention that in the README :).

ncr commented 10 years ago

The streaming is not supported in 1.9 because it uses quite ugly monkey-patching. But it seems people use RackProxy in many some different ways and don't need the streaming at all. You're right, I need to add some info to READMe.

2013/10/6 Sinan Taifour notifications@github.com

Just so I understand your reasoning, does this project not support Ruby 1.9+? If so, it might be a good idea to mention that in the README :).

— Reply to this email directly or view it on GitHubhttps://github.com/ncr/rack-proxy/issues/23#issuecomment-25765013 .

Jacek Becela

http://trix.pl http://github.com/ncr http://linkedin.com/in/jacekbecela http://twitter.com/jacekbecela