goldfinger 1.0.5 → 1.1.0
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.
- checksums.yaml +4 -4
- data/lib/goldfinger/client.rb +7 -5
- data/lib/goldfinger/request.rb +2 -3
- data/lib/goldfinger/result.rb +14 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06a8ef2a1e5478c256b81c6a152c5fdd8681f626
|
4
|
+
data.tar.gz: ca099d14c413a8b3825e19efcd2e2c1930d6fc29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 856a7925e94dce04b68bbc7ca1c116f35f916cd75709b0db1596bb2c8c1424ff8ade41392dcac6d1aa612ec918b7e9d2cb19b53d42b3b7939b7ca7215692e308
|
7
|
+
data.tar.gz: 9bef19672f88c9abf5d29e10c2f1412168ae868277d918c8cadccea39c89d3c1cd8614704b7beba8b7977dfb3f89bee28fe720eb7de9d58321eed9e9f540a6f8
|
data/lib/goldfinger/client.rb
CHANGED
@@ -13,7 +13,7 @@ module Goldfinger
|
|
13
13
|
ssl = true
|
14
14
|
|
15
15
|
begin
|
16
|
-
|
16
|
+
template = perform_get(url(ssl))
|
17
17
|
rescue HTTP::Error
|
18
18
|
if ssl
|
19
19
|
ssl = false
|
@@ -23,11 +23,13 @@ module Goldfinger
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
raise Goldfinger::NotFoundError, "No host-meta on the server" if template.code != 200
|
27
27
|
|
28
|
-
|
28
|
+
response = perform_get(url_from_template(template.body))
|
29
29
|
|
30
|
-
Goldfinger::
|
30
|
+
raise Goldfinger::NotFoundError, "No such user on the server" if response.code != 200
|
31
|
+
|
32
|
+
Goldfinger::Result.new(response)
|
31
33
|
rescue HTTP::Error
|
32
34
|
raise Goldfinger::NotFoundError
|
33
35
|
rescue OpenSSL::SSL::SSLError
|
@@ -48,7 +50,7 @@ module Goldfinger
|
|
48
50
|
|
49
51
|
links.first.attribute('template').value.gsub('{uri}', @uri)
|
50
52
|
rescue Nokogiri::XML::XPath::SyntaxError
|
51
|
-
raise Goldfinger::Error,
|
53
|
+
raise Goldfinger::Error, "Bad XML: #{template}"
|
52
54
|
end
|
53
55
|
|
54
56
|
def domain
|
data/lib/goldfinger/request.rb
CHANGED
@@ -10,14 +10,13 @@ module Goldfinger
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def perform
|
13
|
-
|
14
|
-
[response.headers, response.body]
|
13
|
+
http_client.request(@request_method, @uri.to_s, @options)
|
15
14
|
end
|
16
15
|
|
17
16
|
private
|
18
17
|
|
19
18
|
def http_client
|
20
|
-
HTTP.timeout(:per_operation, write: 60, connect: 20, read: 60)
|
19
|
+
HTTP.timeout(:per_operation, write: 60, connect: 20, read: 60).follow
|
21
20
|
end
|
22
21
|
end
|
23
22
|
end
|
data/lib/goldfinger/result.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
module Goldfinger
|
2
2
|
class Result
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
MIME_TYPES = [
|
4
|
+
'application/jrd+json',
|
5
|
+
'application/json',
|
6
|
+
'application/xrd+xml',
|
7
|
+
'application/xml',
|
8
|
+
'text/xml'
|
9
|
+
].freeze
|
10
|
+
|
11
|
+
def initialize(response)
|
12
|
+
@mime_type = response.mime_type
|
13
|
+
@body = response.body
|
6
14
|
@subject = nil
|
7
15
|
@aliases = []
|
8
16
|
@links = {}
|
@@ -62,8 +70,10 @@ module Goldfinger
|
|
62
70
|
case @mime_type
|
63
71
|
when 'application/jrd+json', 'application/json'
|
64
72
|
parse_json
|
65
|
-
when 'application/xrd+xml'
|
73
|
+
when 'application/xrd+xml', 'application/xml', 'text/xml'
|
66
74
|
parse_xml
|
75
|
+
else
|
76
|
+
raise Goldfinger::Error, "Invalid response mime type: #{@mime_type}"
|
67
77
|
end
|
68
78
|
end
|
69
79
|
|