diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-07-22 05:42:16 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-07-22 09:09:37 +0000 |
commit | 416d3a0f868571319a2b29b0034d2dba68e4d5b3 (patch) | |
tree | 081bdbdcce23063667c707212ceda45bbc322675 /lib/rainbows/rev/client.rb | |
parent | 015daa81f26afc59d1da857b8bbedfb80eb532b1 (diff) | |
download | rainbows-416d3a0f868571319a2b29b0034d2dba68e4d5b3.tar.gz |
The FileStreamer class of EventMachine (and by extension NeverBlock) unfortunately doesn't handle this. It's possible to do with Revactor (since it uses Rev under the covers), but we'll support what we can easily for now.
Diffstat (limited to 'lib/rainbows/rev/client.rb')
-rw-r--r-- | lib/rainbows/rev/client.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/rainbows/rev/client.rb b/lib/rainbows/rev/client.rb index 502615e..2242c18 100644 --- a/lib/rainbows/rev/client.rb +++ b/lib/rainbows/rev/client.rb @@ -80,15 +80,21 @@ module Rainbows st = io.stat if st.file? - write(response_header(status, headers)) if headers - return defer_body(F.new(0, io, body)) + offset, count = 0, st.size + if headers + if range = parse_range(@env, status, headers) + status, offset, count = range + end + write(response_header(status, headers)) + end + return defer_body(F.new(offset, count, io, body)) elsif st.socket? || st.pipe? return stream_response(status, headers, io, body) end # char or block device... WTF? fall through to body.each end write(response_header(status, headers)) if headers - write_body_each(self, body) + write_body_each(self, body, nil) end def app_call |