about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-06-09 21:29:02 +0000
committerEric Wong <normalperson@yhbt.net>2011-06-09 21:29:02 +0000
commitbe467481fe774e60f5a349c6447769f090e57e06 (patch)
treee007e6a80d2850210fb5f6848e9b32b4300b8adb
parent5bd92111979d968fc9b982f1e529b8044e718f71 (diff)
Rack::File already sets Content-Range, so don't repeat work
and reparse Content-Length.
-rw-r--r--lib/rainbows/response.rb10
1 files changed, 9 insertions, 1 deletions
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(/-/)