Class: LameSitemapper::WebHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/web_helper.rb

Class Method Summary collapse

Class Method Details

.get_http_response(url, method = :get) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/web_helper.rb', line 7

def self.get_http_response(url, method=:get)
  response = Typhoeus.send(method, url.to_s, SETTINGS[:web_settings])
  return if response.nil?

  if response.timed_out?
    LOGGER.warn "resource at #{url} timed-out" 
    return
  end

  unless response.success?
    LOGGER.warn "resource at #{url} returned error code #{response.code}" 
    return
  end

  if response.body.nil?
    LOGGER.warn "resource at #{url} returned empty body" 
    return
  end

  response
end