Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make sure max-age is an integer (as specified by RFC2616). Fixes #106.

  • Loading branch information...
commit 1bee791e5bf51828546dcd491122c711a69abbd8 1 parent ad648be
@rkh rkh authored
Showing with 6 additions and 2 deletions.
  1. +5 −1 lib/sinatra/base.rb
  2. +1 −1  test/helpers_test.rb
View
6 lib/sinatra/base.rb
@@ -264,7 +264,11 @@ def cache_control(*values)
end
values = values.map { |value| value.to_s.tr('_','-') }
- hash.each { |k,v| values << [k.to_s.tr('_', '-'), v].join('=') }
+ hash.each do |key, value|
+ key = key.to_s.tr('_', '-')
+ value = value.to_i if key == "max-age"
+ values << [key, value].join('=')
+ end
response['Cache-Control'] = values.join(', ') if values.any?
end
View
2  test/helpers_test.rb
@@ -426,7 +426,7 @@ def send_file_app(opts={})
setup do
mock_app {
get '/' do
- cache_control :public, :no_cache, :max_age => 60
+ cache_control :public, :no_cache, :max_age => 60.0
'Hello World'
end
}
Please sign in to comment.
Something went wrong with that request. Please try again.