handsoap 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 1
4
- :patch: 4
4
+ :patch: 5
5
5
  :build:
@@ -19,12 +19,18 @@ module Handsoap
19
19
  if @curl
20
20
  @curl.url = url
21
21
  else
22
- @curl = ::Curl::Easy.new(url)
23
- @curl.timeout = Handsoap.timeout
24
- @curl.enable_cookies = @enable_cookies
22
+ @curl = ::Curl::Easy.new(url)
23
+ @curl.timeout = Handsoap.timeout
24
+ @curl.enable_cookies = @enable_cookies
25
+
26
+ if Handsoap.follow_redirects?
27
+ @curl.follow_location = true
28
+ @curl.max_redirects = Handsoap.max_redirects
29
+ end
25
30
  end
26
31
  @curl
27
32
  end
33
+
28
34
  private :get_curl
29
35
 
30
36
  def send_http_request(request)
@@ -16,6 +16,8 @@ module Handsoap
16
16
  domain = request.url.match(/^(http(s?):\/\/[^\/]+\/)/)[1]
17
17
  http_client.set_auth(domain, request.username, request.password)
18
18
  end
19
+ http_client.ssl_config.set_trust_ca(request.trust_ca_file) if request.trust_ca_file
20
+ http_client.ssl_config.set_client_cert_file(request.client_cert_file,request.client_cert_key_file) if request.client_cert_file and request.client_cert_key_file
19
21
  # pack headers
20
22
  headers = request.headers.inject([]) do |arr, (k,v)|
21
23
  arr + v.map {|x| [k,x] }
@@ -5,7 +5,7 @@ module Handsoap
5
5
 
6
6
  # Represents a HTTP Request.
7
7
  class Request
8
- attr_reader :url, :http_method, :headers, :body, :username, :password
8
+ attr_reader :url, :http_method, :headers, :body, :username, :password, :trust_ca_file, :client_cert_file, :client_cert_key_file
9
9
  attr_writer :body, :http_method
10
10
  def initialize(url, http_method = :get)
11
11
  @url = url
@@ -14,6 +14,16 @@ module Handsoap
14
14
  @body = nil
15
15
  @username = nil
16
16
  @password = nil
17
+ @trust_ca_file = nil
18
+ @client_cert_file = nil
19
+ @client_cert_key_file = nil
20
+ end
21
+ def set_trust_ca_file(ca_file)
22
+ @trust_ca_file = ca_file
23
+ end
24
+ def set_client_cert_files(client_cert_file,client_cert_key_file)
25
+ @client_cert_file = client_cert_file
26
+ @client_cert_key_file = client_cert_key_file
17
27
  end
18
28
  def set_auth(username, password)
19
29
  @username = username
@@ -35,6 +35,27 @@ module Handsoap
35
35
  def self.timeout
36
36
  @timeout || (self.timeout = 60)
37
37
  end
38
+
39
+ # Tell Handsoap to follow redirects
40
+ def self.follow_redirects!
41
+ @follow_redirects = true
42
+ end
43
+
44
+ # Check whether Handsoap should follow redirects
45
+ def self.follow_redirects?
46
+ @follow_redirects || false
47
+ end
48
+
49
+ # Sets the max number of redirects
50
+ def self.max_redirects=(max_redirects)
51
+ @max_redirects = max_redirects
52
+ end
53
+
54
+ # Fetches the max number of redirects
55
+ # The default is 1
56
+ def self.max_redirects
57
+ @max_redirects || (self.max_redirects = 1)
58
+ end
38
59
 
39
60
  # Wraps SOAP errors in a standard class.
40
61
  class Fault < StandardError
@@ -203,7 +224,11 @@ module Handsoap
203
224
  elsif options[:soap_action] == :none
204
225
  options[:soap_action] = nil
205
226
  end
206
- doc = make_envelope do |body|
227
+ doc = make_envelope do |body,header|
228
+ options[:soap_header].each_pair do |k,v|
229
+ header.add k,v
230
+ end
231
+
207
232
  body.add action
208
233
  end
209
234
  if block_given?
@@ -215,7 +240,7 @@ module Handsoap
215
240
  }
216
241
  headers["SOAPAction"] = options[:soap_action] unless options[:soap_action].nil?
217
242
  on_before_dispatch
218
- request = make_http_request(self.uri, doc.to_s, headers)
243
+ request = make_http_request(self.uri, doc.to_s, headers,options[:http_options])
219
244
  response = http_driver_instance.send_http_request(request)
220
245
  parse_http_response(response)
221
246
  end
@@ -347,8 +372,13 @@ module Handsoap
347
372
  end
348
373
  end
349
374
 
350
- def make_http_request(uri, post_body, headers)
375
+ def make_http_request(uri, post_body, headers,http_options=nil)
351
376
  request = Handsoap::Http::Request.new(uri, :post)
377
+
378
+ # SSL CA AND CLIENT CERTIFICATES
379
+ request.set_trust_ca_file(http_options[:trust_ca_file])
380
+ request.set_client_cert_files(http_options[:client_cert_file],http_options[:client_cert_key_file])
381
+
352
382
  headers.each do |key, value|
353
383
  request.add_header(key, value)
354
384
  end
@@ -399,7 +429,7 @@ module Handsoap
399
429
  self.class.fire_on_create_document doc # deprecated .. use instance method
400
430
  on_create_document(doc)
401
431
  if block_given?
402
- yield doc.find("Body")
432
+ yield doc.find("Body"),doc.find("Header")
403
433
  end
404
434
  return doc
405
435
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handsoap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Troels Knak-Nielsen
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-11-04 00:00:00 +01:00
13
+ date: 2010-01-12 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies: []
16
16