class Rack::PageCaching::Response

Public Class Methods

new(response, env) click to toggle source
# File lib/rack/page_caching/response.rb, line 6
def initialize(response, env)
  @response, @env = response, env
end

Public Instance Methods

body() click to toggle source
# File lib/rack/page_caching/response.rb, line 18
def body
  @response[2]
end
cacheable?() click to toggle source
# File lib/rack/page_caching/response.rb, line 10
def cacheable?
  perform_caching? && caching_allowed?
end
content_type() click to toggle source
# File lib/rack/page_caching/response.rb, line 22
def content_type
  @response[1]['Content-Type'].split(';').first
end
gzip_level() click to toggle source
# File lib/rack/page_caching/response.rb, line 26
def gzip_level
  @env['rack.page_caching.compression'].to_i if @env['rack.page_caching.compression']
end
host() click to toggle source
# File lib/rack/page_caching/response.rb, line 30
def host
  request.host
end
path() click to toggle source
# File lib/rack/page_caching/response.rb, line 14
def path
  @path ||= request.path
end

Private Instance Methods

caching_allowed?() click to toggle source
# File lib/rack/page_caching/response.rb, line 40
def caching_allowed?
  method = @env['REQUEST_METHOD']
  (method == 'GET' || method == 'HEAD') && @response[0] == 200
end
perform_caching?() click to toggle source
# File lib/rack/page_caching/response.rb, line 45
def perform_caching?
  @env['rack.page_caching.perform_caching'].to_s == 'true'
end
request() click to toggle source
# File lib/rack/page_caching/response.rb, line 36
def request
  @request ||= Rack::Request.new(@env)
end