scorn 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lib/scorn.rb +13 -8
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b641e96b08b81079197dad19ae5b9cc0a8cee82e4b2682055d705d3a1bdaff52
4
- data.tar.gz: f35ce97fea114e1e9d754cb44a6e03b9d7834689280de793d9539dd988850552
3
+ metadata.gz: 21ada8f85a3f176d74bca5d1db932477f5d1e76fada2ffe0606d46a2b7424a4f
4
+ data.tar.gz: 6fbe21478d688875fd39cb9d3845781c0f1aae89259ad5c98c14ffbf754fae52
5
5
  SHA512:
6
- metadata.gz: f9bdec0978022c368b95bb9f56f090fcbda07051ee1411f877b54d8aebd60717dd45fd67f659c53e510560db71a4aafbf841d09430e45a5f27267dc78ce2d3db
7
- data.tar.gz: c0f2e3dc90c6b396dbba5f0a7cdba58edbd137bcc05073e83cf173a3a7a07fd70763e1b4ceab8c0c1918a81b5d36b99e2987c5534d51f3d270cb04d4dc914e6f
6
+ metadata.gz: 2edff84c7c87b61652f8c74d4bf89ef755f39470dc7ac3c883eeefba7c155481028c4d0995f795f729d88dbde2cae44b794291a5371e5490824ca165ca4021fa
7
+ data.tar.gz: abd609912fe210f3ae8f91a750c67448f7c08ea6116fdc21c72929037b6580a0b9db4595d1163aacb42d49acf537a05b9ecfc259984bb07db5871617eb223dcf
@@ -2,6 +2,11 @@
2
2
  # CHANGELOG.md
3
3
 
4
4
 
5
+ ## scorn 0.2.0 released 2021-01-05
6
+
7
+ * Don't pass the hostname is GET, it passes in Host:
8
+
9
+
5
10
  ## scorn 0.1.0 released 2021-01-05
6
11
 
7
12
  * Initial release
@@ -10,7 +10,7 @@ require 'net/http'
10
10
 
11
11
  module Scorn
12
12
 
13
- VERSION = '0.1.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
- request(uri, make_get_req(uri, opts))
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
- req = Net::HTTP::Get.new(uri.to_s)
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
- #req.set_header('Accept', 'application/json')
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(u)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scorn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Mettraux