diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-18 15:59:29 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-18 21:25:47 -0700 |
commit | 7b01d94dd9287ac402d91451f1e93c9faaf913c4 (patch) | |
tree | 8f4005f4e92108748af53b8cbf709522f33419db /t/async-response-no-autochunk.ru | |
parent | d0103759ae63b0ed1084f6a9d2b7ede538e8c871 (diff) | |
download | rainbows-7b01d94dd9287ac402d91451f1e93c9faaf913c4.tar.gz |
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.
Diffstat (limited to 't/async-response-no-autochunk.ru')
-rw-r--r-- | t/async-response-no-autochunk.ru | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/t/async-response-no-autochunk.ru b/t/async-response-no-autochunk.ru new file mode 100644 index 0000000..67c6403 --- /dev/null +++ b/t/async-response-no-autochunk.ru @@ -0,0 +1,24 @@ +use Rack::Chunked +use Rainbows::DevFdResponse +script = <<-EOF +for i in 0 1 2 3 4 5 6 7 8 9 +do + printf '1\r\n%s\r\n' $i + sleep 1 +done +printf '0\r\n\r\n' +EOF + +run lambda { |env| + env['rainbows.autochunk'] = false + io = IO.popen(script, 'rb') + io.sync = true + [ + 200, + { + 'Content-Type' => 'text/plain', + 'Transfer-Encoding' => 'chunked', + }, + io + ].freeze +} |