about summary refs log tree commit homepage
path: root/lib/rainbows/response.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-01-05 10:22:11 -0800
committerEric Wong <normalperson@yhbt.net>2011-01-05 10:22:11 -0800
commit89e1f00cd540bca54c2cbcb7d9b6cad5e0e3cf34 (patch)
tree90500052feb9efaaa15a848fd58bf7bc84c248fe /lib/rainbows/response.rb
parent429e9948d91fa159c2daa9944a5026cebb78bade (diff)
downloadrainbows-89e1f00cd540bca54c2cbcb7d9b6cad5e0e3cf34.tar.gz
416 responses without a body should respond with a zero
Content-Length and a Content-Range that allows clients
to specify a proper range in the future.

rfc2616, section 14.16 says:
> A server sending a response with status code 416 (Requested
> range not satisfiable) SHOULD include a Content-Range field
> with a byte-range- resp-spec of "*". The instance-length
> specifies the current length of the selected resource.
Diffstat (limited to 'lib/rainbows/response.rb')
-rw-r--r--lib/rainbows/response.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/rainbows/response.rb b/lib/rainbows/response.rb
index c0d0740..705de62 100644
--- a/lib/rainbows/response.rb
+++ b/lib/rainbows/response.rb
@@ -140,6 +140,8 @@ module Rainbows::Response
       end
 
       if 0 > count || offset >= size
+        headers[Content_Length] = "0"
+        headers[Content_Range] = "bytes */#{clen}"
         return 416, headers, nil
       else
         count = size if count > size