Module: Hackle::HTTP

Defined in:
lib/hackle/internal/http/http.rb

Class Method Summary collapse

Class Method Details

.client(base_url:) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/hackle/internal/http/http.rb', line 8

def self.client(base_url:)
  uri = URI.parse(base_url)
  # noinspection RubyMismatchedArgumentType
  client = Net::HTTP.new(uri.host, uri.port)
  client.use_ssl = uri.scheme == 'https'
  client.open_timeout = 5
  client.read_timeout = 10
  client
end

.not_modified?(response) ⇒ Boolean

Parameters:

  • response (Net::HTTPResponse)

Returns:

  • (Boolean)


24
25
26
# File 'lib/hackle/internal/http/http.rb', line 24

def self.not_modified?(response)
  response.code == '304'
end

.successful?(response) ⇒ Boolean

Parameters:

  • response (Net::HTTPResponse)

Returns:

  • (Boolean)


19
20
21
# File 'lib/hackle/internal/http/http.rb', line 19

def self.successful?(response)
  response.code.start_with?('2')
end