diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-06-06 02:14:58 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-06-06 02:14:58 +0000 |
commit | b1315983056f91467b336aeb426759debc006a4e (patch) | |
tree | 8a0d3dee51038b567dcb72bd4af40d5ff707da9d /lib/rainbows/base.rb | |
parent | 6ada0eb9916bbcebbcf2af843c1f5fb11904caee (diff) | |
download | rainbows-b1315983056f91467b336aeb426759debc006a4e.tar.gz |
centralize body => IO conversion logic
Since EventMachine and Rev shared the same logic for optimizing and avoiding extra file opens for IO/File-ish response bodies, so centralize that. For Ruby 1.9 users, we've also enabled this logic so ThreadPool, ThreadSpawn, WriterThreadPool, and WriterThreadSpawn can take advantage of Rainbows::DevFdResponse-generated bodies while proxying sockets.
Diffstat (limited to 'lib/rainbows/base.rb')
-rw-r--r-- | lib/rainbows/base.rb | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/rainbows/base.rb b/lib/rainbows/base.rb index a773722..8e5031f 100644 --- a/lib/rainbows/base.rb +++ b/lib/rainbows/base.rb @@ -33,8 +33,7 @@ module Rainbows if IO.respond_to?(:copy_stream) def write_body(client, body) if body.respond_to?(:to_path) - io = body.respond_to?(:to_io) ? body.to_io : body.to_path - IO.copy_stream(io, client) + IO.copy_stream(Rainbows.body_to_io(body), client) else body.each { |chunk| client.write(chunk) } end |