From be467481fe774e60f5a349c6447769f090e57e06 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 9 Jun 2011 21:29:02 +0000 Subject: response: sendfile_range fis for Rack::File in rack 1.3.0 Rack::File already sets Content-Range, so don't repeat work and reparse Content-Length. --- lib/rainbows/response.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/rainbows/response.rb b/lib/rainbows/response.rb index fac2c0e..04b12c4 100644 --- a/lib/rainbows/response.rb +++ b/lib/rainbows/response.rb @@ -119,7 +119,15 @@ module Rainbows::Response # This does not support multipart responses (does anybody actually # use those?) def sendfile_range(status, headers) - 200 == status.to_i && + status = status.to_i + if 206 == status + if %r{\Abytes (\d+)-(\d+)/\d+\z} =~ headers[Content_Range] + a, b = $1.to_i, $2.to_i + return 206, headers, [ a, b - a + 1 ] + end + return # wtf... + end + 200 == status && /\Abytes=(\d+-\d*|\d*-\d+)\z/ =~ @hp.env[HTTP_RANGE] or return a, b = $1.split(/-/) -- cgit v1.2.3-24-ge0c7