From 7b01d94dd9287ac402d91451f1e93c9faaf913c4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 18 Oct 2009 15:59:29 -0700 Subject: rev: async response bodies with DevFdResponse middleware This new middleware should be a no-op for non-Rev concurrency models (or by explicitly setting env['rainbows.autochunk'] to false). Setting env['rainbows.autochunk'] to true (the default when Rev is used) allows (e)poll-able IO objects (sockets, pipes) to be sent asynchronously after app.call(env) returns. This also has a fortunate side effect of introducing a code path which allows large, static files to be sent without slurping them into a Rev IO::Buffer, too. This new change works even without the DevFdResponse middleware, so you won't have to reconfigure your app. This lets us epoll on response bodies that come in from a pipe or even a socket and send them either straight through or with chunked encoding. --- lib/rainbows/const.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/rainbows/const.rb') diff --git a/lib/rainbows/const.rb b/lib/rainbows/const.rb index 417a5de..403a18a 100644 --- a/lib/rainbows/const.rb +++ b/lib/rainbows/const.rb @@ -9,6 +9,10 @@ module Rainbows RACK_DEFAULTS = ::Unicorn::HttpRequest::DEFAULTS.merge({ "SERVER_SOFTWARE" => "Rainbows! #{RAINBOWS_VERSION}", + + # using the Rev model, we'll automatically chunk pipe and socket objects + # if they're the response body + 'rainbows.autochunk' => false, }) CONN_CLOSE = "Connection: close\r\n" -- cgit v1.2.3-24-ge0c7