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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a12a3d9db4308744812542f0e74b3d21ae3075fa91b2025114c2693ea20440f1
4
- data.tar.gz: ab01f2d4accd0dfe778936fd2a6a1075cbd45e335f4e34f82f2d6507ebfcd7d0
3
+ metadata.gz: 7d9231125c099e4e5e391e00719bede1da167f044242b6c2604d9690dee0d842
4
+ data.tar.gz: e997c56d4dc24be6cb747e5f1c350cffe2e804dd852a712ca3979381e4c6df03
5
5
  SHA512:
6
- metadata.gz: '0193ebca25917fb8d6be7194a533d6920128213b11a8bf05abb4c093439a5f7c0449b8637af0effcbb139d477a3d0c68bd966567277de4a3f0c670d103a34c75'
7
- data.tar.gz: 473e6a93ba6ba26fb70ec0fdf931e7a1a046c3713c95f49a0b1675ccd4aac7311f00025e7856faed052a7cc20d10a3d0d5b0fbb8848fc24c23b0e08656b2e7ce
6
+ metadata.gz: 3e8c581c55ac7eb75af99f1ec50e2d85324d30f45faae37b45bf920f0bc6a63b5c38ba2ae99f5b98913698208f158dc8f0775e9b2833958a92a4a88dce392547
7
+ data.tar.gz: f870dc8b936d2e64e4d4dc0b06a94cd22527c0675f3317b5cb69b1c6c6e6263fd5a58a6fe35e37e8b87e2f74b535713127c92c525afbdcdb9e56ca9e64def6b8
@@ -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.new(name: DAGGER_NAME)
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)"
@@ -1,6 +1,6 @@
1
1
  module Dagger
2
2
  MAJOR = 1
3
- MINOR = 5
3
+ MINOR = 6
4
4
  PATCH = 1
5
5
 
6
6
  VERSION = [MAJOR, MINOR, PATCH].join('.')
@@ -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.5.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-07 00:00:00.000000000 Z
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