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. 
- 
  
    
      #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_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 | # 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 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 | 
#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
| 32 33 34 35 36 37 | # File 'lib/handsoap/http/request.rb', line 32 def add_header(key, value) if @headers[key].nil? @headers[key] = [] end @headers[key] << value end | 
#inspect ⇒ Object
| 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | # File 'lib/handsoap/http/request.rb', line 45 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
| 28 29 30 31 | # File 'lib/handsoap/http/request.rb', line 28 def set_auth(username, password) @username = username @password = password end | 
#set_client_cert_files(client_cert_file, client_cert_key_file) ⇒ Object
| 24 25 26 27 | # File 'lib/handsoap/http/request.rb', line 24 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
| 38 39 40 41 42 43 44 | # File 'lib/handsoap/http/request.rb', line 38 def set_header(key, value) if value.nil? @headers[key] = nil else @headers[key] = [value] end end | 
#set_trust_ca_file(ca_file) ⇒ Object
| 21 22 23 | # File 'lib/handsoap/http/request.rb', line 21 def set_trust_ca_file(ca_file) @trust_ca_file = ca_file end |