Class: Auger::HttpRequest
Instance Attribute Summary collapse
-
#data(hash) ⇒ Object
Returns the value of attribute data.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#method ⇒ Object
Returns the value of attribute method.
-
#password(password) ⇒ Object
Returns the value of attribute password.
-
#user(user) ⇒ Object
Returns the value of attribute user.
Attributes inherited from Request
#arg, #before_request_proc, #before_tests_proc, #tests
Instance Method Summary collapse
- #header(h) ⇒ Object
-
#initialize(url) ⇒ HttpRequest
constructor
A new instance of HttpRequest.
- #run(http, url) ⇒ Object
Methods inherited from Request
#Result, #Status, #before_request, #before_tests, load, #test, #try_run
Constructor Details
#initialize(url) ⇒ HttpRequest
Returns a new instance of HttpRequest.
67 68 69 70 71 72 |
# File 'lib/auger/plugin/http.rb', line 67 def initialize(url) @method ||= :get # default @headers = {} @data = {} super end |
Instance Attribute Details
#data(hash) ⇒ Object
Returns the value of attribute data.
64 65 66 |
# File 'lib/auger/plugin/http.rb', line 64 def data @data end |
#headers ⇒ Object
Returns the value of attribute headers.
64 65 66 |
# File 'lib/auger/plugin/http.rb', line 64 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method.
64 65 66 |
# File 'lib/auger/plugin/http.rb', line 64 def method @method end |
#password(password) ⇒ Object
Returns the value of attribute password.
64 65 66 |
# File 'lib/auger/plugin/http.rb', line 64 def password @password end |
#user(user) ⇒ Object
Returns the value of attribute user.
64 65 66 |
# File 'lib/auger/plugin/http.rb', line 64 def user @user end |
Instance Method Details
#header(h) ⇒ Object
78 79 80 81 |
# File 'lib/auger/plugin/http.rb', line 78 def header(h) key, value = h.split /\s*:\s*/ @headers[key] = value end |
#run(http, url) ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/auger/plugin/http.rb', line 91 def run(http, url) request = Net::HTTP::const_get(@method.capitalize).new(url) # e.g. Net::HTTP::Get request.basic_auth(@user, @password || '') if @user @headers.each { |k,v| request[k] = v } request.set_form_data(@data) http.request(request) end |