Class: Inspec::Resources::Http
- Inherits:
-
Object
- Object
- Inspec::Resources::Http
- Defined in:
- lib/resources/http.rb
Instance Method Summary collapse
- #body ⇒ Object
- #headers ⇒ Object
-
#initialize(url, opts = {}) ⇒ Http
constructor
A new instance of Http.
- #status ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(url, opts = {}) ⇒ Http
Returns a new instance of Http.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/resources/http.rb', line 27 def initialize(url, opts = {}) @url = url @method = opts.fetch(:method, 'GET') @params = opts.fetch(:params, nil) @auth = opts.fetch(:auth, {}) @headers = opts.fetch(:headers, {}) @data = opts.fetch(:data, nil) @open_timeout = opts.fetch(:open_timeout, 60) @read_timeout = opts.fetch(:read_timeout, 60) @ssl_verify = opts.fetch(:ssl_verify, true) end |
Instance Method Details
#body ⇒ Object
43 44 45 |
# File 'lib/resources/http.rb', line 43 def body response.body end |
#headers ⇒ Object
47 48 49 |
# File 'lib/resources/http.rb', line 47 def headers Hashie::Mash.new(response.headers.to_h) end |
#status ⇒ Object
39 40 41 |
# File 'lib/resources/http.rb', line 39 def status response.status end |
#to_s ⇒ Object
51 52 53 |
# File 'lib/resources/http.rb', line 51 def to_s "http #{@method} on #{@url}" end |