Class: WebLoader::Drivers::HttpDriver

Inherits:
BaseDriver
  • Object
show all
Defined in:
lib/web_loader/drivers/http_driver.rb

Instance Attribute Summary

Attributes inherited from BaseDriver

#binary, #user_agent

Instance Method Summary collapse

Methods inherited from BaseDriver

#initialize

Constructor Details

This class inherits a constructor from WebLoader::Drivers::BaseDriver

Instance Method Details

#fetch(url) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/web_loader/drivers/http_driver.rb', line 11

def fetch(url)
  uri = URI.parse(url)
  http = Net::HTTP.new(uri.host, uri.port)
  if uri.scheme == 'https'
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  end
  response = http.get(uri.request_uri, 'User-Agent' => @user_agent) # request_uri=path + '?' + query
  create_response(response)
end