Module: UrlReader

Extended by:
ActiveSupport::Concern
Includes:
UrlFixer
Defined in:
lib/url_reader.rb

Defined Under Namespace

Modules: UrlFixer Classes: BaseError, CannotResolveEncodingError, FileCache, ReadError

Constant Summary collapse

REQUEST_TIMEOUT =
10
REQUEST_OPEN_TIMEOUT =
10

Instance Method Summary collapse

Methods included from UrlFixer

#fixed_url

Instance Method Details

#read_url(url, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/url_reader.rb', line 17

def read_url(url, options = {})
  self.class.last_response_headers = nil
  self.class.last_response_cookies = nil
  self.class.last_cache_used = false
  if defined?(Rails) && Rails.env.development?
    if ENV['READ_URL_CACHE_NOT_USE'] != 'true'
      ckey = cache_key(url, options)
      if res = cache.read_entry(ckey)
        self.class.last_cache_used = true
        res
      else
        read_url_core_with_cache_write(url, options, ckey)
      end
    else
      read_url_core_with_cache_write(url, options)
    end
  else
    read_url_core(url, options)
  end
end