Class: Inspec::Resources::Http::Worker::Remote

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

Instance Attribute Summary collapse

Attributes inherited from Base

#http_method, #opts, #url

Instance Method Summary collapse

Methods inherited from Base

#resource_id

Constructor Details

#initialize(inspec, http_method, url, opts) ⇒ Remote

Returns a new instance of Remote.



180
181
182
183
184
185
186
187
188
189
# File 'lib/inspec/resources/http.rb', line 180

def initialize(inspec, http_method, url, opts)
  http_cmd = inspec.os.windows? ? "Invoke-WebRequest" : "curl"
  unless inspec.command(http_cmd).exist?
    raise Inspec::Exceptions::ResourceSkipped,
          "#{http_cmd} is not available on the target machine"
  end
  @ran_http = false
  @inspec = inspec
  super(http_method, url, opts)
end

Instance Attribute Details

#inspecObject (readonly)

Returns the value of attribute inspec.



178
179
180
# File 'lib/inspec/resources/http.rb', line 178

def inspec
  @inspec
end

Instance Method Details

#bodyObject



196
197
198
199
# File 'lib/inspec/resources/http.rb', line 196

def body
  run_http
  @body&.strip
end

#response_headersObject



201
202
203
204
# File 'lib/inspec/resources/http.rb', line 201

def response_headers
  run_http
  @response_headers
end

#statusObject



191
192
193
194
# File 'lib/inspec/resources/http.rb', line 191

def status
  run_http
  @status
end