Class: Inspec::Resources::Http
- Inherits:
- 
      Object
      
        - Object
- Inspec::Resources::Http
 
- Defined in:
- lib/resources/http.rb
Defined Under Namespace
Instance Method Summary collapse
- #body ⇒ Object
- #headers ⇒ Object
- #http_method ⇒ 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 38 39 40 41 42 43 44 45 46 47 | # File 'lib/resources/http.rb', line 27 def initialize(url, opts = {}) @url = url @opts = opts # Prior to InSpec 2.0 the HTTP test had to be instructed to run on the # remote target machine. This warning will be removed after a few months # to give users an opportunity to remove the unused option from their # profiles. if opts.key?(:enable_remote_worker) && !inspec.local_transport? warn 'Ignoring `enable_remote_worker` option, the `http` resource ', 'remote worker is enabled by default for remote targets and ', 'cannot be disabled' end # Run locally if InSpec is ran locally and remotely if ran remotely if inspec.local_transport? @worker = Worker::Local.new(http_method, url, opts) else @worker = Worker::Remote.new(inspec, http_method, url, opts) end end | 
Instance Method Details
#body ⇒ Object
| 57 58 59 | # File 'lib/resources/http.rb', line 57 def body @worker.body end | 
#headers ⇒ Object
| 53 54 55 | # File 'lib/resources/http.rb', line 53 def headers @headers ||= Inspec::Resources::Http::Headers.create(@worker.response_headers) end | 
#http_method ⇒ Object
| 61 62 63 | # File 'lib/resources/http.rb', line 61 def http_method @opts.fetch(:method, 'GET') end | 
#status ⇒ Object
| 49 50 51 | # File 'lib/resources/http.rb', line 49 def status @worker.status end | 
#to_s ⇒ Object
| 65 66 67 | # File 'lib/resources/http.rb', line 65 def to_s "http #{http_method} on #{@url}" end |