Permalink
Browse files

Ensure scumbag sendfile middleware always sets the content length to 0.

  • Loading branch information...
1 parent bd3dcda commit d6df4b5165e91b1f90139bd25769b85b1d4b4e43 @josevalim josevalim committed Oct 6, 2011
Showing with 4 additions and 0 deletions.
  1. +1 −0 lib/rack/sendfile.rb
  2. +3 −0 test/spec_sendfile.rb
@@ -105,6 +105,7 @@ def call(env)
when 'X-Accel-Redirect'
path = F.expand_path(body.to_path)
if url = map_accel_path(env, path)
+ headers['Content-Length'] = '0'
headers[type] = url
body = []
else
@@ -40,6 +40,7 @@ def request(headers={})
request 'HTTP_X_SENDFILE_TYPE' => 'X-Sendfile' do |response|
response.should.be.ok
response.body.should.be.empty
+ response.headers['Content-Length'].should == '0'
response.headers['X-Sendfile'].should.equal '/tmp/hello.txt'
end
end
@@ -48,6 +49,7 @@ def request(headers={})
request 'HTTP_X_SENDFILE_TYPE' => 'X-Lighttpd-Send-File' do |response|
response.should.be.ok
response.body.should.be.empty
+ response.headers['Content-Length'].should == '0'
response.headers['X-Lighttpd-Send-File'].should.equal '/tmp/hello.txt'
end
end
@@ -60,6 +62,7 @@ def request(headers={})
request headers do |response|
response.should.be.ok
response.body.should.be.empty
+ response.headers['Content-Length'].should == '0'
response.headers['X-Accel-Redirect'].should.equal '/foo/bar/hello.txt'
end
end

0 comments on commit d6df4b5

Please sign in to comment.