Permalink
Browse files

Merge pull request #250 from josevalim/master

Ensure scumbag sendfile middleware always sets the content length to 0.
  • Loading branch information...
2 parents 2b4216e + d6df4b5 commit f6ee25480307886816e492e1634c63ed18cdf8f6 @raggi raggi committed Oct 18, 2011
Showing with 4 additions and 0 deletions.
  1. +1 −0 lib/rack/sendfile.rb
  2. +3 −0 test/spec_sendfile.rb
View
@@ -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
View
@@ -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 f6ee254

Please sign in to comment.