handsoap 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/DEPLOY.markdown +10 -0
- data/README.markdown +2 -2
- data/VERSION.yml +1 -1
- data/lib/handsoap/http/drivers/curb_driver.rb +18 -1
- data/lib/handsoap/http/drivers/net_http_driver.rb +1 -0
- data/lib/handsoap/service.rb +5 -3
- data/lib/handsoap/xml_query_front.rb +21 -4
- metadata +3 -2
data/DEPLOY.markdown
ADDED
data/README.markdown
CHANGED
data/VERSION.yml
CHANGED
@@ -5,12 +5,29 @@ module Handsoap
|
|
5
5
|
module Http
|
6
6
|
module Drivers
|
7
7
|
class CurbDriver < AbstractDriver
|
8
|
+
attr_accessor :enable_cookies
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@enable_cookies = false
|
12
|
+
end
|
13
|
+
|
8
14
|
def self.load!
|
9
15
|
require 'curb'
|
10
16
|
end
|
11
17
|
|
18
|
+
def get_curl(url)
|
19
|
+
if @curl
|
20
|
+
@curl.url = url
|
21
|
+
else
|
22
|
+
@curl = ::Curl::Easy.new(url)
|
23
|
+
@curl.enable_cookies = @enable_cookies
|
24
|
+
end
|
25
|
+
@curl
|
26
|
+
end
|
27
|
+
private :get_curl
|
28
|
+
|
12
29
|
def send_http_request(request)
|
13
|
-
http_client =
|
30
|
+
http_client = get_curl(request.url)
|
14
31
|
# Set credentials. The driver will negotiate the actual scheme
|
15
32
|
if request.username && request.password
|
16
33
|
http_client.userpwd = [request.username, ":", request.password].join
|
@@ -29,6 +29,7 @@ module Handsoap
|
|
29
29
|
raise "Unsupported request method #{request.http_method}"
|
30
30
|
end
|
31
31
|
http_client = Net::HTTP.new(url.host, url.port)
|
32
|
+
http_client.use_ssl = true if url.scheme == 'https'
|
32
33
|
http_client.read_timeout = 120
|
33
34
|
if request.username && request.password
|
34
35
|
# TODO: http://codesnippets.joyent.com/posts/show/1075
|
data/lib/handsoap/service.rb
CHANGED
@@ -144,6 +144,9 @@ module Handsoap
|
|
144
144
|
def uri
|
145
145
|
self.class.uri
|
146
146
|
end
|
147
|
+
def http_driver_instance
|
148
|
+
Handsoap::Http.drivers[Handsoap.http_driver].new
|
149
|
+
end
|
147
150
|
# Creates an XML document and sends it over HTTP.
|
148
151
|
#
|
149
152
|
# +action+ is the QName of the rootnode of the envelope.
|
@@ -178,8 +181,7 @@ module Handsoap
|
|
178
181
|
headers["SOAPAction"] = options[:soap_action] unless options[:soap_action].nil?
|
179
182
|
on_before_dispatch
|
180
183
|
request = make_http_request(self.uri, doc.to_s, headers)
|
181
|
-
|
182
|
-
response = driver.send_http_request(request)
|
184
|
+
response = http_driver_instance.send_http_request(request)
|
183
185
|
parse_http_response(response)
|
184
186
|
end
|
185
187
|
end
|
@@ -223,7 +225,7 @@ module Handsoap
|
|
223
225
|
headers["SOAPAction"] = options[:soap_action] unless options[:soap_action].nil?
|
224
226
|
on_before_dispatch
|
225
227
|
request = make_http_request(self.uri, doc.to_s, headers)
|
226
|
-
driver =
|
228
|
+
driver = self.http_driver_instance
|
227
229
|
if driver.respond_to? :send_http_request_async
|
228
230
|
deferred = driver.send_http_request_async(request)
|
229
231
|
else
|
@@ -182,6 +182,10 @@ module Handsoap
|
|
182
182
|
def xpath(expression, ns = nil)
|
183
183
|
raise NotImplementedError.new
|
184
184
|
end
|
185
|
+
# Returns a +NodeSelection+
|
186
|
+
def children
|
187
|
+
raise NotImplementedError.new
|
188
|
+
end
|
185
189
|
# Returns the outer XML for this element.
|
186
190
|
def to_xml
|
187
191
|
raise NotImplementedError.new
|
@@ -218,6 +222,9 @@ module Handsoap
|
|
218
222
|
assert_prefixes!(expression, ns)
|
219
223
|
NodeSelection.new(@element.find(expression, ns.map{|k,v| "#{k}:#{v}" }).to_a.map{|node| LibXMLDriver.new(node, ns) })
|
220
224
|
end
|
225
|
+
def children
|
226
|
+
NodeSelection.new(@element.children.map{|node| LibXMLDriver.new(node) })
|
227
|
+
end
|
221
228
|
def [](attribute_name)
|
222
229
|
raise ArgumentError.new unless attribute_name.kind_of? String
|
223
230
|
@element[attribute_name]
|
@@ -243,7 +250,11 @@ module Handsoap
|
|
243
250
|
class REXMLDriver
|
244
251
|
include XmlElement
|
245
252
|
def node_name
|
246
|
-
@element.name
|
253
|
+
if @element.respond_to? :name
|
254
|
+
@element.name
|
255
|
+
else
|
256
|
+
@element.class.name.gsub(/.*::([^:]+)$/, "\\1").downcase
|
257
|
+
end
|
247
258
|
end
|
248
259
|
def xpath(expression, ns = nil)
|
249
260
|
ns = {} if ns.nil?
|
@@ -251,6 +262,9 @@ module Handsoap
|
|
251
262
|
assert_prefixes!(expression, ns)
|
252
263
|
NodeSelection.new(REXML::XPath.match(@element, expression, ns).map{|node| REXMLDriver.new(node, ns) })
|
253
264
|
end
|
265
|
+
def children
|
266
|
+
NodeSelection.new(@element.children.map{|node| REXMLDriver.new(node) })
|
267
|
+
end
|
254
268
|
def [](attribute_name)
|
255
269
|
raise ArgumentError.new unless attribute_name.kind_of? String
|
256
270
|
@element.attributes[attribute_name]
|
@@ -267,10 +281,10 @@ module Handsoap
|
|
267
281
|
@element.to_s
|
268
282
|
end
|
269
283
|
def to_s
|
270
|
-
if @element.
|
271
|
-
@element.value
|
272
|
-
else
|
284
|
+
if @element.respond_to? :text
|
273
285
|
@element.text
|
286
|
+
else
|
287
|
+
@element.value
|
274
288
|
end
|
275
289
|
end
|
276
290
|
end
|
@@ -289,6 +303,9 @@ module Handsoap
|
|
289
303
|
assert_prefixes!(expression, ns)
|
290
304
|
NodeSelection.new(@element.xpath(expression, ns).map{|node| NokogiriDriver.new(node, ns) })
|
291
305
|
end
|
306
|
+
def children
|
307
|
+
NodeSelection.new(@element.children.map{|node| NokogiriDriver.new(node) })
|
308
|
+
end
|
292
309
|
def [](attribute_name)
|
293
310
|
raise ArgumentError.new unless attribute_name.kind_of? String
|
294
311
|
@element[attribute_name]
|
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
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Troels Knak-Nielsen
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-15 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -22,6 +22,7 @@ extensions: []
|
|
22
22
|
extra_rdoc_files:
|
23
23
|
- README.markdown
|
24
24
|
files:
|
25
|
+
- DEPLOY.markdown
|
25
26
|
- README.markdown
|
26
27
|
- VERSION.yml
|
27
28
|
- generators/handsoap/USAGE
|