Class: Auger::HttpRequest
Instance Attribute Summary collapse
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#password(password) ⇒ Object
Returns the value of attribute password.
-
#user(user) ⇒ Object
Returns the value of attribute user.
Attributes inherited from Request
#arg, #before_tests_proc, #response, #tests
Instance Method Summary collapse
- #header(h) ⇒ Object
-
#initialize(url) ⇒ HttpRequest
constructor
A new instance of HttpRequest.
- #run(http) ⇒ Object
Methods inherited from Request
#before_tests, #do_run, load, #test
Constructor Details
#initialize(url) ⇒ HttpRequest
Returns a new instance of HttpRequest.
41 42 43 44 |
# File 'lib/plugins/http.rb', line 41 def initialize(url) @headers = {} super end |
Instance Attribute Details
#headers ⇒ Object
Returns the value of attribute headers.
39 40 41 |
# File 'lib/plugins/http.rb', line 39 def headers @headers end |
#password(password) ⇒ Object
Returns the value of attribute password.
39 40 41 |
# File 'lib/plugins/http.rb', line 39 def password @password end |
#user(user) ⇒ Object
Returns the value of attribute user.
39 40 41 |
# File 'lib/plugins/http.rb', line 39 def user @user end |
Instance Method Details
#header(h) ⇒ Object
46 47 48 49 |
# File 'lib/plugins/http.rb', line 46 def header(h) key, value = h.split /\s*:\s*/ @headers[key] = value end |
#run(http) ⇒ Object
59 60 61 62 63 64 |
# File 'lib/plugins/http.rb', line 59 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 |