Class: Auger::HttpRequest
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body(string) ⇒ Object
Returns the value of attribute body.
-
#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.
71 72 73 74 75 76 |
# File 'lib/auger/plugin/http.rb', line 71 def initialize(url) @method ||= :get # default @headers = {} @data = {} super end |
Instance Attribute Details
#body(string) ⇒ Object
Returns the value of attribute body.
68 69 70 |
# File 'lib/auger/plugin/http.rb', line 68 def body @body end |
#data(hash) ⇒ Object
Returns the value of attribute data.
68 69 70 |
# File 'lib/auger/plugin/http.rb', line 68 def data @data end |
#headers ⇒ Object
Returns the value of attribute headers.
68 69 70 |
# File 'lib/auger/plugin/http.rb', line 68 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method.
68 69 70 |
# File 'lib/auger/plugin/http.rb', line 68 def method @method end |
#password(password) ⇒ Object
Returns the value of attribute password.
68 69 70 |
# File 'lib/auger/plugin/http.rb', line 68 def password @password end |
#user(user) ⇒ Object
Returns the value of attribute user.
68 69 70 |
# File 'lib/auger/plugin/http.rb', line 68 def user @user end |
Instance Method Details
#header(h) ⇒ Object
86 87 88 89 |
# File 'lib/auger/plugin/http.rb', line 86 def header(h) key, value = h.split /\s*:\s*/ @headers[key] = value end |
#run(http, url) ⇒ Object
99 100 101 102 103 104 105 106 |
# File 'lib/auger/plugin/http.rb', line 99 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) request.body = @body http.request(request) end |