rev: async response bodies with DevFdResponse middleware
commit7b01d94dd9287ac402d91451f1e93c9faaf913c4
authorEric Wong <normalperson@yhbt.net>
Sun, 18 Oct 2009 22:59:29 +0000 (18 15:59 -0700)
committerEric Wong <normalperson@yhbt.net>
Mon, 19 Oct 2009 04:25:47 +0000 (18 21:25 -0700)
tree8f4005f4e92108748af53b8cbf709522f33419db
parentd0103759ae63b0ed1084f6a9d2b7ede538e8c871
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.
23 files changed:
lib/rainbows.rb
lib/rainbows/const.rb
lib/rainbows/dev_fd_response.rb [new file with mode: 0644]
lib/rainbows/http_server.rb
lib/rainbows/rev.rb
t/async-response-no-autochunk.ru [new file with mode: 0644]
t/async-response.ru [new file with mode: 0644]
t/large-file-response.ru [new file with mode: 0644]
t/lib-async-response-no-autochunk.sh [new file with mode: 0644]
t/lib-async-response.sh [new file with mode: 0644]
t/lib-large-file-response.sh [new file with mode: 0644]
t/t1004-thread-pool-async-response.sh [new symlink]
t/t1005-thread-pool-large-file-response.sh [new symlink]
t/t1006-thread-pool-async-response-no-autochunk.sh [new symlink]
t/t2004-thread-spawn-async-response.sh [new symlink]
t/t2005-thread-spawn-large-file-response.sh [new symlink]
t/t2006-thread-spawn-async-response-no-autochunk.sh [new symlink]
t/t3004-revactor-async-response.sh [new symlink]
t/t3005-revactor-large-file-response.sh [new file with mode: 0755]
t/t3006-revactor-async-response-no-autochunk.sh [new symlink]
t/t4004-rev-async-response.sh [new symlink]
t/t4005-rev-large-file-response.sh [new file with mode: 0755]
t/t4006-rev-async-response-no-autochunk.sh [new symlink]