diff --git a/lib/rack/sendfile.rb b/lib/rack/sendfile.rb index 75ccbf836..c82145ae0 100644 --- a/lib/rack/sendfile.rb +++ b/lib/rack/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 diff --git a/test/spec_sendfile.rb b/test/spec_sendfile.rb index 84517e7ef..de4ae7ac9 100644 --- a/test/spec_sendfile.rb +++ b/test/spec_sendfile.rb @@ -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