1 # Filters added to this controller apply to all controllers in the application.
2 # Likewise, all the methods added will be available for all controllers.
7 class ApplicationController < ActionController::Base
9 layout "application_no_js"
11 after_filter :set_vary_header
12 after_filter :compress
15 self.response.headers['Vary'] = 'Accept-Encoding'
19 enc = self.request.env['HTTP_ACCEPT_ENCODING']
20 if enc and (md = enc.match(/gzip;?(q=([^,]*))?/))
21 if md[1].nil? or md[2].to_f > 0.0
22 if self.response.headers["Content-Transfer-Encoding"] != 'binary'
23 logger.debug "compressing output"
25 ostream = StringIO.new
26 gz = Zlib::GzipWriter.new(ostream)
27 gz.write(self.response.body)
28 self.response.body = ostream.string
29 self.response.headers['Content-Encoding'] = 'gzip'
38 def rescue_action_in_public(exception)
39 @message = exception.message
41 render :template => "error", :layout => :false, :status => 404
43 render :template => 'error', :layout => "application", :status => 404