scorn 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/scorn.rb +13 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21ada8f85a3f176d74bca5d1db932477f5d1e76fada2ffe0606d46a2b7424a4f
|
4
|
+
data.tar.gz: 6fbe21478d688875fd39cb9d3845781c0f1aae89259ad5c98c14ffbf754fae52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2edff84c7c87b61652f8c74d4bf89ef755f39470dc7ac3c883eeefba7c155481028c4d0995f795f729d88dbde2cae44b794291a5371e5490824ca165ca4021fa
|
7
|
+
data.tar.gz: abd609912fe210f3ae8f91a750c67448f7c08ea6116fdc21c72929037b6580a0b9db4595d1163aacb42d49acf537a05b9ecfc259984bb07db5871617eb223dcf
|
data/CHANGELOG.md
CHANGED
data/lib/scorn.rb
CHANGED
@@ -10,7 +10,7 @@ require 'net/http'
|
|
10
10
|
|
11
11
|
module Scorn
|
12
12
|
|
13
|
-
VERSION = '0.
|
13
|
+
VERSION = '0.2.0'
|
14
14
|
|
15
15
|
class << self
|
16
16
|
|
@@ -48,19 +48,24 @@ module Scorn
|
|
48
48
|
|
49
49
|
def get(uri, opts)
|
50
50
|
|
51
|
-
|
51
|
+
u = uri.is_a?(String) ? URI(uri) : uri
|
52
|
+
|
53
|
+
request(u, make_get_req(u, opts))
|
52
54
|
end
|
53
55
|
|
54
56
|
protected
|
55
57
|
|
56
58
|
def make_get_req(uri, opts)
|
57
59
|
|
58
|
-
|
60
|
+
u = [ uri.path, uri.query ].compact.join('?')
|
61
|
+
u = '/' if u.length < 1
|
62
|
+
|
63
|
+
req = Net::HTTP::Get.new(u)
|
59
64
|
req.instance_eval { @header.clear }
|
60
65
|
def req.set_header(k, v); @header[k] = [ v ]; end
|
61
66
|
|
62
67
|
req.set_header('User-Agent', user_agent)
|
63
|
-
|
68
|
+
req.set_header('Accept', '*/*')
|
64
69
|
|
65
70
|
req
|
66
71
|
end
|
@@ -69,12 +74,9 @@ module Scorn
|
|
69
74
|
|
70
75
|
def request(uri, req)
|
71
76
|
|
72
|
-
u = uri.is_a?(String) ? URI(uri) : uri
|
73
|
-
|
74
77
|
t0 = monow
|
75
78
|
|
76
|
-
http = make_net_http(
|
77
|
-
#t.set_debug_output($stdout) if u.to_s.match?(/search/)
|
79
|
+
http = make_net_http(uri)
|
78
80
|
|
79
81
|
res = http.request(req)
|
80
82
|
|
@@ -96,6 +98,9 @@ module Scorn
|
|
96
98
|
|
97
99
|
http = Net::HTTP.new(uri.host, uri.port)
|
98
100
|
|
101
|
+
http.set_debug_output(@opts[:debug])
|
102
|
+
#http.set_debug_output($stderr)
|
103
|
+
|
99
104
|
if uri.scheme == 'https'
|
100
105
|
http.use_ssl = true
|
101
106
|
http.verify_mode = ssl_verify_mode
|