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/rev/deferred_response.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/rev/deferred_response.rb')
-rw-r--r-- | lib/rainbows/rev/deferred_response.rb | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/lib/rainbows/rev/deferred_response.rb b/lib/rainbows/rev/deferred_response.rb index dd7a229..62a308c 100644 --- a/lib/rainbows/rev/deferred_response.rb +++ b/lib/rainbows/rev/deferred_response.rb @@ -17,12 +17,7 @@ module Rainbows return HttpResponse.write(client, response, out) headers = HH.new(headers) - - # to_io is not part of the Rack spec, but make an exception - # here since we can't get here without checking to_path first - io = body.to_io if body.respond_to?(:to_io) - io ||= ::IO.new($1.to_i) if body.to_path =~ %r{\A/dev/fd/(\d+)\z} - io ||= File.open(body.to_path, 'rb') + io = Rainbows.body_to_io(body) st = io.stat if st.socket? || st.pipe? |