Permalink
Browse files

Use streaming response to handle enumerable bodies.

  • Loading branch information...
1 parent d404376 commit f5a08cdf94d3619d9c981e6e52853e7b42b01482 @SebastianEdwards SebastianEdwards committed May 16, 2012
Showing with 8 additions and 9 deletions.
  1. +8 −9 lib/webmachine/adapters/reel.rb
@@ -32,15 +32,14 @@ def process(connection)
LazyRequestBody.new(wreq))
response = Webmachine::Response.new
@dispatcher.dispatch(request,response)
- # TODO: Chunked encoding support? This completely misses the
- # opportunity to stream efficiently.
- body = case response.body
- when String
- response.body
- when Enumerable
- response.body.to_a.join
- end
- wres = ::Reel::Response.new(response.code, response.headers, body)
+
+ wres = case response.body
+ when String
+ ::Reel::Response.new(response.code, response.headers, response.body)
+ when Enumerable
+ ::Reel::StreamingResponse.new(response.code, response.headers, response.body)
+ end
+
connection.respond(wres)
end
end

0 comments on commit f5a08cd

Please sign in to comment.