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
-
.get_request(url, headers = {}, timeouts = {}) ⇒ Object
Makes a GET http request and returns it’s response.
- .put_request(url, headers = {}, timeouts = {}) ⇒ Object
Class Method Details
.get_request(url, headers = {}, timeouts = {}) ⇒ Object
Makes a GET http request and returns it’s response.
Params: url: String which contains the address to which the request will be made headers: Hash which contains the headers you need to add to your request.
Default headers is an empty hash
Example: { "Accept": 'application/json' }
timeouts: Hash that includes the values for the session and connection timeouts.
Example: { session: 2.4. connection: 5 }
Return value: is a string with the response body if the response code is 200. If the response code is not 200, an empty string is returned.
26 27 28 |
# File 'lib/facter/util/resolvers/http.rb', line 26 def get_request(url, headers = {}, timeouts = {}) make_request(url, headers, timeouts, 'GET') end |
.put_request(url, headers = {}, timeouts = {}) ⇒ Object
30 31 32 |
# File 'lib/facter/util/resolvers/http.rb', line 30 def put_request(url, headers = {}, timeouts = {}) make_request(url, headers, timeouts, 'PUT') end |