Class: Handsoap::Http::Request
- Inherits:
-
Object
- Object
- Handsoap::Http::Request
- Defined in:
- lib/handsoap/http.rb
Overview
Represents a HTTP Request.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #add_header(key, value) ⇒ Object
-
#initialize(url, http_method = :get) ⇒ Request
constructor
A new instance of Request.
- #inspect ⇒ Object
- #set_header(key, value) ⇒ Object
Constructor Details
#initialize(url, http_method = :get) ⇒ Request
Returns a new instance of Request.
11 12 13 14 15 16 |
# File 'lib/handsoap/http.rb', line 11 def initialize(url, http_method = :get) @url = url @http_method = http_method @headers = {} @body = nil end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
9 10 11 |
# File 'lib/handsoap/http.rb', line 9 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/handsoap/http.rb', line 9 def headers @headers end |
#http_method ⇒ Object
Returns the value of attribute http_method.
9 10 11 |
# File 'lib/handsoap/http.rb', line 9 def http_method @http_method end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/handsoap/http.rb', line 9 def url @url end |
Instance Method Details
#add_header(key, value) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/handsoap/http.rb', line 17 def add_header(key, value) if @headers[key].nil? @headers[key] = [] end @headers[key] << value end |
#inspect ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/handsoap/http.rb', line 30 def inspect "===============\n" + "--- Request ---\n" + "#{http_method.to_s.upcase} #{url}\n" + ( if headers.any? "---\n" + headers.map { |key,values| values.map {|value| key + ": " + value + "\n" }.join("") }.join("") else "" end ) + ( if body "---\n" + body else "" end ) end |
#set_header(key, value) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/handsoap/http.rb', line 23 def set_header(key, value) if value.nil? @headers[key] = nil else @headers[key] = [value] end end |