Class: Inspec::Resources::Http

Inherits:
Object
  • Object
show all
Defined in:
lib/resources/http.rb

Instance Method Summary collapse

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

#bodyObject



43
44
45
# File 'lib/resources/http.rb', line 43

def body
  response.body
end

#headersObject



47
48
49
# File 'lib/resources/http.rb', line 47

def headers
  Hashie::Mash.new(response.headers.to_h)
end

#statusObject



39
40
41
# File 'lib/resources/http.rb', line 39

def status
  response.status
end

#to_sObject



51
52
53
# File 'lib/resources/http.rb', line 51

def to_s
  "http #{@method} on #{@url}"
end