Merge pull request #1096 from mwpastore/fix-s-maxage

Fix s-maxage and value coercion
This commit is contained in:
Kashyap 2016-02-25 07:42:10 +05:30
commit 4c7d38eb1b
1 changed files with 2 additions and 2 deletions

View File

@ -446,7 +446,7 @@ module Sinatra
# Specify response freshness policy for HTTP caches (Cache-Control header). # Specify response freshness policy for HTTP caches (Cache-Control header).
# Any number of non-value directives (:public, :private, :no_cache, # Any number of non-value directives (:public, :private, :no_cache,
# :no_store, :must_revalidate, :proxy_revalidate) may be passed along with # :no_store, :must_revalidate, :proxy_revalidate) may be passed along with
# a Hash of value directives (:max_age, :min_stale, :s_max_age). # a Hash of value directives (:max_age, :min_stale, :s_maxage).
# #
# cache_control :public, :must_revalidate, :max_age => 60 # cache_control :public, :must_revalidate, :max_age => 60
# => Cache-Control: public, must-revalidate, max-age=60 # => Cache-Control: public, must-revalidate, max-age=60
@ -465,7 +465,7 @@ module Sinatra
values.map! { |value| value.to_s.tr('_','-') } values.map! { |value| value.to_s.tr('_','-') }
hash.each do |key, value| hash.each do |key, value|
key = key.to_s.tr('_', '-') key = key.to_s.tr('_', '-')
value = value.to_i if key == "max-age" value = value.to_i if ['max-age', 's-maxage'].include? key
values << "#{key}=#{value}" values << "#{key}=#{value}"
end end