Class: Auger::HttpRequest

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

Instance Attribute Summary collapse

Attributes inherited from Request

#arg, #before_tests_proc, #tests

Instance Method Summary collapse

Methods inherited from Request

#Result, #before_tests, #do_run, load, #test

Constructor Details

#initialize(url) ⇒ HttpRequest

Returns a new instance of HttpRequest.



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

def initialize(url)
  @headers = {}
  super
end

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



41
42
43
# File 'lib/plugins/http.rb', line 41

def headers
  @headers
end

#password(password) ⇒ Object

Returns the value of attribute password.



41
42
43
# File 'lib/plugins/http.rb', line 41

def password
  @password
end

#user(user) ⇒ Object

Returns the value of attribute user.



41
42
43
# File 'lib/plugins/http.rb', line 41

def user
  @user
end

Instance Method Details

#header(h) ⇒ Object



48
49
50
51
# File 'lib/plugins/http.rb', line 48

def header(h)
  key, value = h.split /\s*:\s*/
  @headers[key] = value
end

#run(http) ⇒ Object



61
62
63
64
65
66
# File 'lib/plugins/http.rb', line 61

def run(http)
  get = Net::HTTP::Get.new(@arg)
  get.basic_auth(@user, @password||'') if @user
  @headers.each { |k,v| get[k] = v }
  http.request(get)
end