Module: HTTPX::Plugins::ResponseCache::RequestMethods
- Defined in:
- lib/httpx/plugins/response_cache.rb
Instance Attribute Summary collapse
-
#cached_response ⇒ Object
points to a previously cached Response corresponding to this request.
Instance Method Summary collapse
-
#cacheable_verb? ⇒ Boolean
returns whether this request is cacheable as per HTTP caching rules.
- #initialize ⇒ Object
- #merge_headers ⇒ Object
-
#response_cache_key ⇒ Object
returns a unique cache key as a String identifying this request.
Instance Attribute Details
#cached_response ⇒ Object
points to a previously cached Response corresponding to this request.
185 186 187 |
# File 'lib/httpx/plugins/response_cache.rb', line 185 def cached_response @cached_response end |
Instance Method Details
#cacheable_verb? ⇒ Boolean
returns whether this request is cacheable as per HTTP caching rules.
198 199 200 |
# File 'lib/httpx/plugins/response_cache.rb', line 198 def cacheable_verb? CACHEABLE_VERBS.include?(@verb) end |
#initialize ⇒ Object
187 188 189 190 |
# File 'lib/httpx/plugins/response_cache.rb', line 187 def initialize(*) super @cached_response = nil end |
#merge_headers ⇒ Object
192 193 194 195 |
# File 'lib/httpx/plugins/response_cache.rb', line 192 def merge_headers(*) super @response_cache_key = nil end |
#response_cache_key ⇒ Object
returns a unique cache key as a String identifying this request
203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/httpx/plugins/response_cache.rb', line 203 def response_cache_key @response_cache_key ||= begin keys = [@verb, @uri] @options.supported_vary_headers.each do |field| value = @headers[field] keys << value if value end Digest::SHA1.hexdigest("httpx-response-cache-#{keys.join("-")}") end end |