goldfinger 1.1.2 → 1.2.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 +33 -14
- 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: 7b9f439ace3badfbfd7be9f56df56d275b831973
|
4
|
+
data.tar.gz: 6bfef9289937a10a6681a22b6ff8f02fd39024ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88dae51709e0a492b830f57f6e57b5b47714f42c572b4b582aa54d330bcd9ffacfcbb640a7b677e1b8ec586fcee62477353a42addeb2f9759075405c8948d13d
|
7
|
+
data.tar.gz: 02af661772034400db9f96df7097d5f0c838b83c11778931afbd7551718d0e403158c4ab6eed1d9bb5f2ca2334964c04170377382f89288efb9a87436c6c020c
|
data/lib/goldfinger/client.rb
CHANGED
@@ -13,23 +13,17 @@ module Goldfinger
|
|
13
13
|
ssl = true
|
14
14
|
|
15
15
|
begin
|
16
|
-
|
17
|
-
rescue HTTP::Error
|
18
|
-
if ssl
|
19
|
-
ssl = false
|
20
|
-
retry
|
21
|
-
else
|
22
|
-
raise Goldfinger::NotFoundError
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
raise Goldfinger::NotFoundError, 'No host-meta on the server' if template.code != 200
|
16
|
+
response = perform_get(standard_url(ssl))
|
27
17
|
|
28
|
-
|
18
|
+
return finger_from_template if response.code != 200
|
29
19
|
|
30
|
-
|
20
|
+
Goldfinger::Result.new(response)
|
21
|
+
rescue HTTP::Error
|
22
|
+
raise Goldfinger::NotFoundError unless ssl
|
31
23
|
|
32
|
-
|
24
|
+
ssl = false
|
25
|
+
retry
|
26
|
+
end
|
33
27
|
rescue HTTP::Error
|
34
28
|
raise Goldfinger::NotFoundError
|
35
29
|
rescue OpenSSL::SSL::SSLError
|
@@ -40,10 +34,35 @@ module Goldfinger
|
|
40
34
|
|
41
35
|
private
|
42
36
|
|
37
|
+
def finger_from_template
|
38
|
+
ssl = true
|
39
|
+
|
40
|
+
begin
|
41
|
+
template = perform_get(url(ssl))
|
42
|
+
rescue HTTP::Error
|
43
|
+
raise Goldfinger::NotFoundError unless ssl
|
44
|
+
|
45
|
+
ssl = false
|
46
|
+
retry
|
47
|
+
end
|
48
|
+
|
49
|
+
raise Goldfinger::NotFoundError, 'No host-meta on the server' if template.code != 200
|
50
|
+
|
51
|
+
response = perform_get(url_from_template(template.body))
|
52
|
+
|
53
|
+
raise Goldfinger::NotFoundError, 'No such user on the server' if response.code != 200
|
54
|
+
|
55
|
+
Goldfinger::Result.new(response)
|
56
|
+
end
|
57
|
+
|
43
58
|
def url(ssl = true)
|
44
59
|
"http#{'s' if ssl}://#{domain}/.well-known/host-meta"
|
45
60
|
end
|
46
61
|
|
62
|
+
def standard_url(ssl = true)
|
63
|
+
"http#{'s' if ssl}://#{domain}/.well-known/webfinger?resource=#{@uri}"
|
64
|
+
end
|
65
|
+
|
47
66
|
def url_from_template(template)
|
48
67
|
xml = Nokogiri::XML(template)
|
49
68
|
links = xml.xpath('//xmlns:Link[@rel="lrdd"]')
|