support for svgz gzip

This commit is contained in:
Thomas Reynolds 2011-11-26 23:09:18 -08:00
parent 4cfbd6e5d9
commit 7ab8f0cdd1
3 changed files with 6 additions and 2 deletions

View file

@ -1,6 +1,7 @@
%h1 Welcome %h1 Welcome
= image_tag "Chrome_Logo.svg" = image_tag "Chrome_Logo.svg"
= image_tag "cfb_tomb-perennial-energy.svgz"
:markdown :markdown
## H2 ## H2

View file

@ -432,13 +432,16 @@ protected
# #
# @param [String] File to send # @param [String] File to send
def send_file(path) def send_file(path)
matched_mime = mime_type(File.extname(path)) extension = File.extname(path)
matched_mime = mime_type(extension)
matched_mime = "application/octet-stream" if matched_mime.nil? matched_mime = "application/octet-stream" if matched_mime.nil?
content_type matched_mime content_type matched_mime
file = ::Rack::File.new nil file = ::Rack::File.new nil
file.path = path file.path = path
halt file.serving(env) response = file.serving(env)
response[1]['Content-Encoding'] = 'gzip' if %w(.svgz).include?(extension)
halt response
end end
# Set the content type for the current request # Set the content type for the current request