Class: HTTP::Session::Request

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/http/session/request.rb

Overview

Provides access to the HTTP request.

Mostly borrowed from rack-cache/lib/rack/cache/request.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(*args) ⇒ Object



7
8
9
# File 'lib/http/session/request.rb', line 7

def new(*args)
  args[0].is_a?(self) ? args[0] : super
end

Instance Method Details

#cache_controlCache::CacheControl

A CacheControl instance based on the request's cache-control header.

Returns:



15
16
17
# File 'lib/http/session/request.rb', line 15

def cache_control
  @cache_control ||= HTTP::Session::Cache::CacheControl.new(headers[HTTP::Headers::CACHE_CONTROL])
end

#cacheable?Boolean

Determine if the request is worth caching under any circumstance.

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/http/session/request.rb', line 25

def cacheable?
  return false if verb != :get && verb != :head
  return false if cache_control.no_store?
  true
end

#no_cache?Boolean

True when the cache-control/no-cache directive is present.

Returns:

  • (Boolean)


20
21
22
# File 'lib/http/session/request.rb', line 20

def no_cache?
  cache_control.no_cache?
end