Class: Handsoap::Http::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/handsoap/http/request.rb

Overview

Represents a HTTP Request.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Request) initialize(url, http_method = :get)



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

- (Object) body

Returns the value of attribute body



8
9
10
# File 'lib/handsoap/http/request.rb', line 8

def body
  @body
end

- (Object) client_cert_file (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

- (Object) client_cert_key_file (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

- (Object) headers (readonly)

Returns the value of attribute headers



8
9
10
# File 'lib/handsoap/http/request.rb', line 8

def headers
  @headers
end

- (Object) http_method

Returns the value of attribute http_method



8
9
10
# File 'lib/handsoap/http/request.rb', line 8

def http_method
  @http_method
end

- (Object) password (readonly)

Returns the value of attribute password



8
9
10
# File 'lib/handsoap/http/request.rb', line 8

def password
  @password
end

- (Object) ssl_verify_mode (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

- (Object) trust_ca_file (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

- (Object) url (readonly)

Returns the value of attribute url



8
9
10
# File 'lib/handsoap/http/request.rb', line 8

def url
  @url
end

- (Object) username (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

- (Object) add_header(key, value)



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

- (Object) inspect



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

- (Object) set_auth(username, password)



32
33
34
35
# File 'lib/handsoap/http/request.rb', line 32

def set_auth(username, password)
  @username = username
  @password = password
end

- (Object) set_client_cert_files(client_cert_file, client_cert_key_file)



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

- (Object) set_header(key, value)



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

- (Object) set_ssl_verify_mode(mode)



29
30
31
# File 'lib/handsoap/http/request.rb', line 29

def set_ssl_verify_mode(mode)
  @ssl_verify_mode = mode
end

- (Object) set_trust_ca_file(ca_file)



22
23
24
# File 'lib/handsoap/http/request.rb', line 22

def set_trust_ca_file(ca_file)
  @trust_ca_file = ca_file
end