Skip to content

Commit

Permalink
Merge pull request rack#250 from josevalim/master
Browse files Browse the repository at this point in the history
Ensure scumbag sendfile middleware always sets the content length to 0.
  • Loading branch information
raggi committed Oct 18, 2011
2 parents 2b4216e + d6df4b5 commit f6ee254
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rack/sendfile.rb
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/spec_sendfile.rb
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f6ee254

Please sign in to comment.