Class: HttpDownloader::Http::Request

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

Constant Summary collapse

HTTP =
'http'
HTTPS =
'https'

Instance Method Summary collapse

Constructor Details

#initialize(uri, headers = {}, http_options = {}) ⇒ Request

Returns a new instance of Request.



7
8
9
10
11
# File 'lib/http_downloader/http/request.rb', line 7

def initialize(uri, headers = {}, http_options = {})
  @uri           = uri
  @headers       = headers
  @http_options  = http_options
end

Instance Method Details

#executeObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/http_downloader/http/request.rb', line 13

def execute
  response = nil
  byebug
  Net::HTTP.start(@uri.host, @uri.port, http_options(@uri)) do |http|
    request = Net::HTTP::Get.new(@uri, @headers)
    http.request(request) do |http_response|
      response = http_response
    end
  end
  response
end