summaryrefslogtreecommitdiff
path: root/test/spec_files.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/spec_files.rb')
-rw-r--r--test/spec_files.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/spec_files.rb b/test/spec_files.rb
index f74e5195..b65a7cfd 100644
--- a/test/spec_files.rb
+++ b/test/spec_files.rb
@@ -192,6 +192,20 @@ describe Rack::Files do
res.body.must_equal "IS FILE! ***"
end
+ it "handle case where file is truncated during request" do
+ env = Rack::MockRequest.env_for("/cgi/test")
+ env["HTTP_RANGE"] = "bytes=0-3300"
+ files = Class.new(Rack::Files) do
+ def filesize(_); 10000 end
+ end.new(DOCROOT)
+
+ res = Rack::MockResponse.new(*files.call(env))
+
+ res.status.must_equal 206
+ res["content-length"].must_equal "209"
+ res["content-range"].must_equal "bytes 0-3300/10000"
+ end
+
it "return correct multiple byte ranges in body" do
env = Rack::MockRequest.env_for("/cgi/test")
env["HTTP_RANGE"] = "bytes=22-33, 60-80"