dagger 1.5.1 → 1.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dagger.rb +11 -3
- data/lib/dagger/version.rb +1 -1
- data/spec/ip_connect_spec.rb +17 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d9231125c099e4e5e391e00719bede1da167f044242b6c2604d9690dee0d842
|
4
|
+
data.tar.gz: e997c56d4dc24be6cb747e5f1c350cffe2e804dd852a712ca3979381e4c6df03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e8c581c55ac7eb75af99f1ec50e2d85324d30f45faae37b45bf920f0bc6a63b5c38ba2ae99f5b98913698208f158dc8f0775e9b2833958a92a4a88dce392547
|
7
|
+
data.tar.gz: f870dc8b936d2e64e4d4dc0b06a94cd22527c0675f3317b5cb69b1c6c6e6263fd5a58a6fe35e37e8b87e2f74b535713127c92c525afbdcdb9e56ca9e64def6b8
|
data/lib/dagger.rb
CHANGED
@@ -65,9 +65,10 @@ module Dagger
|
|
65
65
|
def self.init(uri, opts)
|
66
66
|
uri = Utils.parse_uri(uri)
|
67
67
|
http = if opts.delete(:persistent)
|
68
|
-
Net::HTTP::Persistent
|
68
|
+
pool_size = opts[:pool_size] || Net::HTTP::Persistent::DEFAULT_POOL_SIZE
|
69
|
+
Net::HTTP::Persistent.new(name: DAGGER_NAME, pool_size: pool_size)
|
69
70
|
else
|
70
|
-
Net::HTTP.new(uri.host, uri.port)
|
71
|
+
Net::HTTP.new(opts[:ip] || uri.host, uri.port)
|
71
72
|
end
|
72
73
|
|
73
74
|
if uri.port == 443
|
@@ -89,12 +90,18 @@ module Dagger
|
|
89
90
|
|
90
91
|
def get(uri, opts = {})
|
91
92
|
uri = Utils.resolve_uri(uri, @host, opts[:query])
|
93
|
+
|
92
94
|
raise ArgumentError.new("#{uri.scheme_and_host} does not match #{@host}") if @host != uri.scheme_and_host
|
93
95
|
|
94
96
|
opts[:follow] = 10 if opts[:follow] == true
|
95
97
|
headers = opts[:headers] || {}
|
96
98
|
headers['Accept'] = 'application/json' if opts[:json] && headers['Accept'].nil?
|
97
99
|
|
100
|
+
if opts[:ip]
|
101
|
+
headers['Host'] = uri.host
|
102
|
+
uri = opts[:ip]
|
103
|
+
end
|
104
|
+
|
98
105
|
request = Net::HTTP::Get.new(uri, DEFAULT_HEADERS.merge(headers))
|
99
106
|
request.basic_auth(opts.delete(:username), opts.delete(:password)) if opts[:username]
|
100
107
|
|
@@ -102,6 +109,7 @@ module Dagger
|
|
102
109
|
@http.start unless @http.started?
|
103
110
|
resp, data = @http.request(request)
|
104
111
|
else # persistent
|
112
|
+
puts @http.pool.inspect
|
105
113
|
resp, data = @http.request(uri, request)
|
106
114
|
end
|
107
115
|
|
@@ -114,7 +122,7 @@ module Dagger
|
|
114
122
|
@response = build_response(resp, data || resp.body)
|
115
123
|
|
116
124
|
rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EINVAL, Timeout::Error, \
|
117
|
-
SocketError, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, OpenSSL::SSL::SSLError => e
|
125
|
+
SocketError, EOFError, Net::ReadTimeout, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, OpenSSL::SSL::SSLError => e
|
118
126
|
|
119
127
|
if retries = opts[:retries] and retries.to_i > 0
|
120
128
|
puts "Got #{e.class}! Retrying in a sec (#{retries} retries left)"
|
data/lib/dagger/version.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require './lib/dagger'
|
2
|
+
|
3
|
+
require 'rspec/mocks'
|
4
|
+
require 'rspec/expectations'
|
5
|
+
|
6
|
+
describe 'IP Connection' do
|
7
|
+
|
8
|
+
it 'works' do
|
9
|
+
expect do
|
10
|
+
Dagger.get('http://www.awiefjoawijfaowef.com')
|
11
|
+
end.to raise_error(SocketError, /getaddrinfo/)
|
12
|
+
|
13
|
+
resp = Dagger.get('http://www.awiefjoawijfaowef.com', { ip: '1.1.1.1'} )
|
14
|
+
expect(resp.body).to match('<center>cloudflare</center>')
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dagger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomás Pollak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/dagger/response.rb
|
130
130
|
- lib/dagger/version.rb
|
131
131
|
- spec/arguments_spec.rb
|
132
|
+
- spec/ip_connect_spec.rb
|
132
133
|
- spec/parsers_spec.rb
|
133
134
|
- spec/persistent_spec.rb
|
134
135
|
homepage: https://github.com/tomas/dagger
|