Module: Facter::Util::Resolvers::Http

Defined in:
lib/facter/util/resolvers/http.rb

Constant Summary collapse

CONNECTION_TIMEOUT =
0.6
SESSION_TIMEOUT =
5

Class Method Summary collapse

Class Method Details

.get_request(url, headers = {}, timeouts = {}, proxy = true) ⇒ Object

Makes a GET HTTP request and returns its response.

Examples:

get_request('https://example.com', { "Accept": 'application/json' }, { session: 2.4, connection: 5 })

Parameters:

  • url (String)

    the address to which the request will be made.

  • headers (Hash) (defaults to: {})

    the headers you need to add to your request. Defaults to an empty hash.

  • timeouts (Hash) (defaults to: {})

    Values for the session and connection timeouts.

  • proxy (Boolean) (defaults to: true)

    Whether to use proxy settings when calling Net::HTTP.new. Defaults to true.



26
27
28
# File 'lib/facter/util/resolvers/http.rb', line 26

def get_request(url, headers = {}, timeouts = {}, proxy = true)
  make_request(url, headers, timeouts, 'GET', proxy)
end

.put_request(url, headers = {}, timeouts = {}, proxy = true) ⇒ Object

Makes a PUT HTTP request and returns its response



33
34
35
# File 'lib/facter/util/resolvers/http.rb', line 33

def put_request(url, headers = {}, timeouts = {}, proxy = true)
  make_request(url, headers, timeouts, 'PUT', proxy)
end