xcapclient 1.2 → 1.2.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/README.rdoc +1 -1
- data/lib/xcapclient.rb +1 -1
- data/lib/xcapclient/client.rb +19 -11
- metadata +2 -2
data/README.rdoc
CHANGED
data/lib/xcapclient.rb
CHANGED
data/lib/xcapclient/client.rb
CHANGED
@@ -128,7 +128,7 @@ module XCAPClient
|
|
128
128
|
|
129
129
|
@identity_header = conf[:identity_header].freeze
|
130
130
|
@identity_user = ( conf[:identity_user].freeze || @user ) if @identity_header
|
131
|
-
COMMON_HEADERS[@identity_header] = @identity_user if @identity_header
|
131
|
+
COMMON_HEADERS[@identity_header] = '"' + @identity_user + '"' if @identity_header
|
132
132
|
|
133
133
|
# Initialize the HTTP client.
|
134
134
|
@http_client = HTTPClient.new
|
@@ -429,7 +429,8 @@ module XCAPClient
|
|
429
429
|
# the document stored in the server. This methods allows the client
|
430
430
|
# to fetch these namespaces and prefixes.
|
431
431
|
#
|
432
|
-
# Related documentation: {RFC 4825 section 7.10}[http://tools.ietf.org/html/rfc4825#section-7.10],
|
432
|
+
# Related documentation: {RFC 4825 section 7.10}[http://tools.ietf.org/html/rfc4825#section-7.10],
|
433
|
+
# {RFC 4825 section 10}[http://tools.ietf.org/html/rfc4825#section-10]
|
433
434
|
#
|
434
435
|
# Example:
|
435
436
|
#
|
@@ -471,15 +472,16 @@ module XCAPClient
|
|
471
472
|
#
|
472
473
|
# Related documentation: {RFC 4825 section 12}[http://tools.ietf.org/html/rfc4825#section-12]
|
473
474
|
#
|
474
|
-
# If Nokogiri[http://wiki.github.com/tenderlove/nokogiri] is available the method returns an
|
475
|
+
# If Nokogiri[http://wiki.github.com/tenderlove/nokogiri] is available the method returns an
|
476
|
+
# Array containing the auids. If not, the response body is returned as a String.
|
475
477
|
#
|
476
478
|
def get_xcap_auids
|
477
479
|
|
478
|
-
body = get_node("xcap-caps", nil, '
|
480
|
+
body = get_node("xcap-caps", nil, 'xcap-caps/auids')
|
479
481
|
|
480
482
|
return case NOKOGIRI_INSTALLED
|
481
483
|
when true
|
482
|
-
parse(body).xpath("
|
484
|
+
parse(body).xpath("auids/auid", {"xmlns" => XCAP_CAPS_XMLNS}).map {|auid| auid.content}
|
483
485
|
when false
|
484
486
|
body
|
485
487
|
end
|
@@ -493,11 +495,11 @@ module XCAPClient
|
|
493
495
|
#
|
494
496
|
def get_xcap_extensions
|
495
497
|
|
496
|
-
body = get_node("xcap-caps", nil, '
|
498
|
+
body = get_node("xcap-caps", nil, 'xcap-caps/extensions')
|
497
499
|
|
498
500
|
return case NOKOGIRI_INSTALLED
|
499
501
|
when true
|
500
|
-
parse(body).xpath("
|
502
|
+
parse(body).xpath("extensions/extension", {"xmlns" => XCAP_CAPS_XMLNS}).map {|extension| extension.content}
|
501
503
|
when false
|
502
504
|
body
|
503
505
|
end
|
@@ -511,11 +513,11 @@ module XCAPClient
|
|
511
513
|
#
|
512
514
|
def get_xcap_namespaces
|
513
515
|
|
514
|
-
body = get_node("xcap-caps", nil, '
|
516
|
+
body = get_node("xcap-caps", nil, 'xcap-caps/namespaces')
|
515
517
|
|
516
518
|
return case NOKOGIRI_INSTALLED
|
517
519
|
when true
|
518
|
-
parse(body).xpath("
|
520
|
+
parse(body).xpath("namespaces/namespace", {"xmlns" => XCAP_CAPS_XMLNS}).map {|namespace| namespace.content}
|
519
521
|
when false
|
520
522
|
body
|
521
523
|
end
|
@@ -651,12 +653,18 @@ module XCAPClient
|
|
651
653
|
end # def send_request
|
652
654
|
|
653
655
|
|
656
|
+
# http://tools.ietf.org/html/rfc3986#section-3.3
|
657
|
+
# I add "/" and "@" as they must not be escaped.
|
658
|
+
# I remove "&", "?" so they must be escaped now.
|
659
|
+
ESCAPE_CHARS = "[^a-zA-Z0-9\\-._~!$&'()*+,=:;/@]"
|
660
|
+
|
654
661
|
def percent_encode(str)
|
662
|
+
### NOTE: I've removed "&", "?" so they must be escaped now.
|
655
663
|
return case RUBY_VERSION_CORE
|
656
664
|
when :RUBY_1_9
|
657
|
-
str.dup.force_encoding('ASCII-8BIT').gsub(/
|
665
|
+
str.dup.force_encoding('ASCII-8BIT').gsub(/#{ESCAPE_CHARS}/) { '%%%02x' % $&.ord }
|
658
666
|
when :RUBY_1_8
|
659
|
-
str.gsub(/
|
667
|
+
str.gsub(/#{ESCAPE_CHARS}/n) {|s| sprintf('%%%02x', s[0]) }
|
660
668
|
end
|
661
669
|
end
|
662
670
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcapclient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "I\xC3\xB1aki Baz Castillo"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-30 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|