Class: Handsoap::Http::Request
- Inherits:
-
Object
- Object
- Handsoap::Http::Request
- Defined in:
- lib/handsoap/http/request.rb
Overview
Represents a HTTP Request.
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#client_cert_file ⇒ Object
readonly
Returns the value of attribute client_cert_file.
-
#client_cert_key_file ⇒ Object
readonly
Returns the value of attribute client_cert_key_file.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#ssl_verify_mode ⇒ Object
readonly
Returns the value of attribute ssl_verify_mode.
-
#trust_ca_file ⇒ Object
readonly
Returns the value of attribute trust_ca_file.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #add_header(key, value) ⇒ Object
-
#initialize(url, http_method = :get) ⇒ Request
constructor
A new instance of Request.
- #inspect ⇒ Object
- #set_auth(username, password) ⇒ Object
- #set_client_cert_files(client_cert_file, client_cert_key_file) ⇒ Object
- #set_header(key, value) ⇒ Object
- #set_ssl_verify_mode(mode) ⇒ Object
- #set_trust_ca_file(ca_file) ⇒ Object
Constructor Details
#initialize(url, http_method = :get) ⇒ Request
Returns a new instance of Request.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/handsoap/http/request.rb', line 10 def initialize(url, http_method = :get) @url = url @http_method = http_method @headers = {} @body = nil @username = nil @password = nil @trust_ca_file = nil @client_cert_file = nil @client_cert_key_file = nil @ssl_verify_mode = nil end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
8 9 10 |
# File 'lib/handsoap/http/request.rb', line 8 def body @body end |
#client_cert_file ⇒ Object (readonly)
Returns the value of attribute client_cert_file.
8 9 10 |
# File 'lib/handsoap/http/request.rb', line 8 def client_cert_file @client_cert_file end |
#client_cert_key_file ⇒ Object (readonly)
Returns the value of attribute client_cert_key_file.
8 9 10 |
# File 'lib/handsoap/http/request.rb', line 8 def client_cert_key_file @client_cert_key_file end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/handsoap/http/request.rb', line 8 def headers @headers end |
#http_method ⇒ Object
Returns the value of attribute http_method.
8 9 10 |
# File 'lib/handsoap/http/request.rb', line 8 def http_method @http_method end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
8 9 10 |
# File 'lib/handsoap/http/request.rb', line 8 def password @password end |
#ssl_verify_mode ⇒ Object (readonly)
Returns the value of attribute ssl_verify_mode.
8 9 10 |
# File 'lib/handsoap/http/request.rb', line 8 def ssl_verify_mode @ssl_verify_mode end |
#trust_ca_file ⇒ Object (readonly)
Returns the value of attribute trust_ca_file.
8 9 10 |
# File 'lib/handsoap/http/request.rb', line 8 def trust_ca_file @trust_ca_file end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/handsoap/http/request.rb', line 8 def url @url end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
8 9 10 |
# File 'lib/handsoap/http/request.rb', line 8 def username @username end |
Instance Method Details
#add_header(key, value) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/handsoap/http/request.rb', line 36 def add_header(key, value) if @headers[key].nil? @headers[key] = [] end @headers[key] << value end |
#inspect ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/handsoap/http/request.rb', line 49 def inspect "===============\n" + "--- Request ---\n" + "#{http_method.to_s.upcase} #{url}\n" + ( if username && password "Auth credentials: #{username}:#{password}\n" else "" end ) + ( 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_auth(username, password) ⇒ Object
32 33 34 35 |
# File 'lib/handsoap/http/request.rb', line 32 def set_auth(username, password) @username = username @password = password end |
#set_client_cert_files(client_cert_file, client_cert_key_file) ⇒ Object
25 26 27 28 |
# File 'lib/handsoap/http/request.rb', line 25 def set_client_cert_files(client_cert_file,client_cert_key_file) @client_cert_file = client_cert_file @client_cert_key_file = client_cert_key_file end |
#set_header(key, value) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/handsoap/http/request.rb', line 42 def set_header(key, value) if value.nil? @headers[key] = nil else @headers[key] = [value] end end |
#set_ssl_verify_mode(mode) ⇒ Object
29 30 31 |
# File 'lib/handsoap/http/request.rb', line 29 def set_ssl_verify_mode(mode) @ssl_verify_mode = mode end |
#set_trust_ca_file(ca_file) ⇒ Object
22 23 24 |
# File 'lib/handsoap/http/request.rb', line 22 def set_trust_ca_file(ca_file) @trust_ca_file = ca_file end |