rails/rails — Issue #5225: Rails 3.1 & 3.2 -- Can't get Sendfile to work
Author: docwhat
Created: 2012-03-01 06:54:19+00:00
State: open

I cannot get the `Rack::Sendfile` stuff to work with the compiled assets no matter how hard I try. This is with Rails 3.1 and 3.2.1 both.

## Steps to reproduce:

```bash

ruby -v # => ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.3.0]
rails -v # => Rails 3.2.1
rails new myapp
cd myapp/
vim config/environments/production.rb
# I uncomment: config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
env RAILS_ENV=production rake assets:precompile
env RAILS_ENV=production rackup -p 3000
curl -s -o/dev/null -H 'X-Sendfile-Type: X-Sendfile' -D- http://localhost:3000/assets/rails.png
```

## What I expect:
```
HTTP/1.1 200 OK
...
X-Sendfile: /tmp/myapp/public/assets/rails.png
```

## What I got:

```
HTTP/1.1 404 Not Found
Content-Type: text/html; charset=utf-8
Content-Length: 728
X-Request-Id: c42e676c9a8c53cb844c661ad184eb18
X-Runtime: 0.732327
Date: Thu, 01 Mar 2012 06:50:16 GMT
X-Rack-Cache: miss
Server: WEBrick/1.3.1 (Ruby/1.9.2/2011-07-09)
Connection: Keep-Alive
```

## Notes

Tracing down to Rack::Sendfile itself, I see that the response's body does not `respond_to? :to_path`. The object it has is a bunch of `Proxy` objects which I don't grok.

I hope this is enough information to figure this out.

Ciao!