2017-07-19 23:36:11 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-02-17 15:13:19 +01:00
|
|
|
require 'http'
|
|
|
|
require 'addressable'
|
|
|
|
|
|
|
|
module Goldfinger
|
|
|
|
class Request
|
|
|
|
def initialize(request_method, path, options = {})
|
|
|
|
@request_method = request_method
|
|
|
|
@uri = Addressable::URI.parse(path)
|
|
|
|
@options = options
|
|
|
|
end
|
|
|
|
|
|
|
|
def perform
|
2016-10-12 20:58:17 +02:00
|
|
|
http_client.request(@request_method, @uri.to_s, @options)
|
2016-02-17 15:13:19 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def http_client
|
2019-01-14 10:23:20 +01:00
|
|
|
HTTP.timeout(write: 60, connect: 20, read: 60).follow
|
2016-02-17 15:13:19 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|