Closed rfletcher closed 11 years ago
What version of ruby are you running this on? I believe for Ruby 1.9+ compatibility the body of the triplet needs to be wrapped in an array otherwise you will get an error on must handlers: Rack::Lint::LintError: Response body must respond to each
triplet = [target_response.code, headers, [target_response.body]]
I use 1.9.3.
You're right, the body needs to respond to #each, but target_response
will be either an HttpStreamingResponse
or a Net::HTTP
instance. In both cases the value of #body already responds to #each. An Array
shouldn't be necessary.
More generally, this pull request doesn't change anything about this method's behavior. It just simplifies the logic of target_response
initialization.
Proxy#perform_request
has gotten pretty big, specifically thetarget_response
initialization. I've refactored that part a little, removing duplication.The only meaningful change was renaming
HttpStreamingResponse#status
to#code
, so that its API matchesNet::HTTP#code
. I've added an alias so that#status
keeps woking, in case someone's using it externally.