sinatra/sinatra — pull request #770 by patriciomacadden (2013-09-16 01:13:35+00:00)
Title: Don't delete Content-Length header if it's a head request or if the body is a Rack::File

See #739.

The problem is that the `Content-Length` header is calculated (or not) depending on the web server:

* WEBrick calculates the `Content-Length` header
* Thin does not calculate the `Content-Length` header (See https://github.com/macournoyer/thin/blob/master/CHANGELOG#L39-L40)
* Puma does not calculate the `Content-Length` header (I smoke-tested it!)

I couldn't add a test, because there's already one (See https://github.com/sinatra/sinatra/blob/master/test/helpers_test.rb#L814-L818) and it doesn't fail. However, with a simple app you can reproduce the error:

* `file.txt`

```
Hello World!
```

* `config.ru`

```
require 'sinatra'

get '/' do
send_file 'file.txt'
end

run Sinatra::Application
```

And then running it with WEBrick, thin and puma.

@rkh would you review this, please?