Browse files

Eliminate Rack::File headers deprecation warning

rake test produces:
   "Rack::File headers parameter replaces cache_control after Rack 1.5."

Despite what the message says, it appears that the hearders parameter change
will be effective as of Rack 1.5:
  • Loading branch information...
1 parent c67005f commit 9cc82b77196d21a5c7021f6dca59ab9b2b158a45 @rubys rubys committed Jan 8, 2013
Showing with 1 addition and 1 deletion.
  1. +1 −1 actionpack/lib/action_dispatch/middleware/static.rb
2 actionpack/lib/action_dispatch/middleware/static.rb
@@ -6,7 +6,7 @@ class FileHandler
def initialize(root, cache_control)
@root = root.chomp('/')
@compiled_root = /^#{Regexp.escape(root)}/
- @file_server =, cache_control)
+ @file_server =, 'Cache-Control' => cache_control)
def match?(path)

7 comments on commit 9cc82b7



I think this introduced a bug.

[2013-01-10 20:36:04] ERROR NoMethodError: undefined method `split' for nil:NilClass
gems/rack-1.4.3/lib/rack/handler/webrick.rb:69:in `block in service'
gems/rack-1.4.3/lib/rack/utils.rb:387:in `block in each'

This happens because of:

{"Last-Modified"=>"Thu, 10 Jan 2013 19:17:43 GMT", "Content-Type"=>"text/html", "Cache-Control"=>nil, "Content-Length"=>"82"}


touch public/foo.html
curl http://localhost:3000/foo.html

By default cache_control is nil in development/production.

Ruby on Rails member

@dn it'd be great if you could produce a test case for us to fix it.


Would love to, I can only provide you with a simple example how to reproduce it.

touch public/foo.html
rails s
curl http://localhost:3000/foo.html

In the cache_control is set, but even if I would nil it it will still not trigger the error, because in the test Rack::MockRequest is used and because of that is never reached and the bug is not visible.

Can you reproduce the error - if so I would keep investigating how to write a simple test for it?


Maybe this explain it a bit further Rack does not expect a nil value in the header, but "Cache-Control"=>nil for a static file.

rails s
curl http://localhost:3000/robots.txt

Will also trigger the error. I'll try to write a test/fix for it.

Ruby on Rails member

@dn @carlosantoniodasilva was this issue addressed?

Ruby on Rails member

Saw that it's fixed here #8907 thanks

Ruby on Rails member


Please sign in to comment.