net-http-persistent 3.0.1 → 3.1.0

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: 544b6c4e52caee7104e021181a7ab8723a625e239820297b7e6d87934c7e0e0e
4
- data.tar.gz: 03e9df91b7e30d25886c30a650f9e6feb8fa7d945cf5e61b19d416bfe46eff6a
3
+ metadata.gz: 8dc2ad1abe3b0e82c9a23ed65f74425262d7ef4209768c8e309af861628179d9
4
+ data.tar.gz: d34075303f6bbb7483bfd05e8054ecbd839a371c6ef5d29c844d21bd50834316
5
5
  SHA512:
6
- metadata.gz: 38b3695f98f1bae796fb0b51b12d992b621ac9d0d8b6e9f885c9327a91d994acdfa18e37018bf5a7a28bf52e11413194b027dd332d3605f913c66f847402d683
7
- data.tar.gz: 32420e4a50e91fcac562ab34b1c383a7ce529d0c6646a802e4625f5f61b4c017ef6640d4e466bd803d4a5d0172d577cd05ef1979a450ef326af68a76de4f709a
6
+ metadata.gz: ed24bcd001852e4ade23285d7a7912735d8db4e1f6088e0ea0b8e037c49035fc2dce0efba6e0326a8a745453f503a6f23bf52fe472995dcc9d9ada7b6e177991
7
+ data.tar.gz: 73f7dffd85bbe34cc71086aa352e12cd203b26480126b1f9dfefe4c722215dbcae9707bcfcb6b880c1f542cb2b1299e7a423f18504aa9964c9ac2ba3b6300325
@@ -0,0 +1,2 @@
1
+ x"%<���5������?�^_���ru�/]�-��>ʝ�qH�O�R,��0����$W� N�Xζ~���o�^��Z�7,���0�J�A�8ڽ0�]�m�M����v9�74��m _na���)���'+�o��X6-k���'�_
2
+ h����.��*�R|R U�Ջ��;�o"��X�e0 �k�3�шɑ�p�����wo�ΪK��C�dÈ%aIFD�C�`(.,"[�g���_�+��ŵ�s�Ъ�
Binary file
@@ -2,14 +2,23 @@
2
2
  after_script:
3
3
  - rake travis:after -t
4
4
  before_script:
5
- - gem install hoe-travis --no-rdoc --no-ri
5
+ - gem install hoe-travis --no-document
6
6
  - rake travis:before -t
7
7
  language: ruby
8
8
  notifications:
9
9
  email:
10
10
  - drbrain@segment7.net
11
11
  rvm:
12
- - 2.1.10
13
- - 2.2.5
14
- - 2.3.1
12
+ - 2.1
13
+ - 2.2
14
+ - 2.3
15
+ - 2.4
16
+ - 2.5
17
+ - 2.6
15
18
  script: rake travis
19
+ install: "" # avoid running default bundler install
20
+
21
+ matrix:
22
+ include:
23
+ - rvm: "2.6"
24
+ env: TRAVIS_MATRIX=pipeline
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ # -*- ruby -*-
2
+
3
+ # DO NOT EDIT THIS FILE. Instead, edit Rakefile, and run `rake bundler:gemfile`.
4
+
5
+ source "https://rubygems.org/"
6
+
7
+ gem "connection_pool", "~>2.2"
8
+
9
+ gem "minitest", "~>5.11", :group => [:development, :test]
10
+ gem "hoe-bundler", "~>1.5", :group => [:development, :test]
11
+ gem "hoe-travis", "~>1.4", ">=1.4.1", :group => [:development, :test]
12
+ gem "rdoc", ">=4.0", "<7", :group => [:development, :test]
13
+ gem "hoe", "~>3.17", :group => [:development, :test]
14
+
15
+ # vim: syntax=ruby
@@ -1,4 +1,41 @@
1
- === 3.0
1
+ === 3.1.0 2019-07-24
2
+
3
+ New features:
4
+ * Support ruby 2.6 Net::HTTP#write_timeout=. Pull request #99 by Víctor
5
+ Roldán Betancort.
6
+ * Support setting TLS min/max version. Pull request #94 by Bart.
7
+
8
+ Bug fixes:
9
+ * Reduce potential for memory leak through Hash default proc bindings. Pull
10
+ request #64 by Dominic Metzger.
11
+ * Test proxy auto detection from no_proxy in ENV. Pull request #60 by
12
+ HINOHARA Hiroshi.
13
+ * Add missing timestamp for 3.0 release. Pull request #78 by Joe Van Dyk.
14
+ * Support IPv6 URLs in proxy checks. Pull request #82 by Nicolás Sanguinetti.
15
+ * Use Net::HTTPGenericRequest#method to check idempotence for improved
16
+ compatibility. Pull request #83 by Fotos Georgiadis.
17
+ * Run net-http-pipeline tests in travis. Pull request #86 by T.J. Schuck.
18
+ * Correct +no_proxy+ support to override Net::HTTP proxy fallback. Pull
19
+ request #88 by Jared Kauppila.
20
+ * Mitigate memory leak when combined with faraday. Pull request #105 by Yohei
21
+ Kitamura.
22
+ * Set default connection pool size for Windows. Pull request #90 by Jared
23
+ Kauppila.
24
+ * Fix missing +name:+ argument in documentation. Pull requests #85 by T.J.
25
+ Schuck, #84 by James White.
26
+ * Fix memory leak from connection pooling. Pull request #97 by Aaron
27
+ Patterson.
28
+ * Update tests for minitest assert_equal deprecation. Pull request #92 by
29
+ Olle Jonsson.
30
+ * Fix typo in Net::HTTP::Persistent#pipeline. Pull request #91 by Kazuma
31
+ Furuhashi.
32
+
33
+ Other:
34
+ * Added bundler hoe plugin. Pull request #103 by Michael Grosser.
35
+ * Updated ruby versions in Travis CI. Pull request #93 by Olle Jonsson. Pull
36
+ request #103 by Michael Grosser.
37
+
38
+ === 3.0 2016-10-05
2
39
 
3
40
  Breaking changes:
4
41
 
@@ -1,6 +1,7 @@
1
1
  .autotest
2
2
  .gemtest
3
3
  .travis.yml
4
+ Gemfile
4
5
  History.txt
5
6
  Manifest.txt
6
7
  README.rdoc
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
1
  # -*- ruby -*-
2
2
 
3
- require 'rubygems'
4
3
  require 'hoe'
5
4
 
5
+ Hoe.plugin :bundler
6
6
  Hoe.plugin :git
7
7
  Hoe.plugin :minitest
8
8
  Hoe.plugin :travis
@@ -20,8 +20,12 @@ Hoe.spec 'net-http-persistent' do
20
20
  rdoc_locations <<
21
21
  'docs.seattlerb.org:/data/www/docs.seattlerb.org/net-http-persistent/'
22
22
 
23
- dependency 'connection_pool', '~> 2.2'
24
- dependency 'minitest', '~> 5.2', :development
23
+ dependency 'connection_pool', '~> 2.2'
24
+ dependency 'minitest', '~> 5.2', :development
25
+ dependency 'hoe-bundler', '~> 1.5', :development
26
+ dependency 'hoe-travis', ['~> 1.4', '>= 1.4.1'], :development
27
+ dependency 'net-http-pipeline', '~> 1.0' if
28
+ ENV['TRAVIS_MATRIX'] == 'pipeline'
25
29
  end
26
30
 
27
31
  # vim: syntax=Ruby
@@ -202,12 +202,16 @@ class Net::HTTP::Persistent
202
202
  ##
203
203
  # The default connection pool size is 1/4 the allowed open files.
204
204
 
205
- DEFAULT_POOL_SIZE = Process.getrlimit(Process::RLIMIT_NOFILE).first / 4
205
+ if Gem.win_platform? then
206
+ DEFAULT_POOL_SIZE = 256
207
+ else
208
+ DEFAULT_POOL_SIZE = Process.getrlimit(Process::RLIMIT_NOFILE).first / 4
209
+ end
206
210
 
207
211
  ##
208
212
  # The version of Net::HTTP::Persistent you are using
209
213
 
210
- VERSION = '3.0.1'
214
+ VERSION = '3.1.0'
211
215
 
212
216
  ##
213
217
  # Exceptions rescued for automatic retry on ruby 2.0.0. This overlaps with
@@ -406,6 +410,11 @@ class Net::HTTP::Persistent
406
410
 
407
411
  attr_accessor :read_timeout
408
412
 
413
+ ##
414
+ # Seconds to wait until writing one block. See Net::HTTP#write_timeout
415
+
416
+ attr_accessor :write_timeout
417
+
409
418
  ##
410
419
  # By default SSL sessions are reused to avoid extra SSL handshakes. Set
411
420
  # this to false if you have problems communicating with an HTTPS server
@@ -530,6 +539,7 @@ class Net::HTTP::Persistent
530
539
  @keep_alive = 30
531
540
  @open_timeout = nil
532
541
  @read_timeout = nil
542
+ @write_timeout = nil
533
543
  @idle_timeout = 5
534
544
  @max_requests = nil
535
545
  @socket_options = []
@@ -623,10 +633,13 @@ class Net::HTTP::Persistent
623
633
  def connection_for uri
624
634
  use_ssl = uri.scheme.downcase == 'https'
625
635
 
626
- net_http_args = [uri.host, uri.port]
636
+ net_http_args = [uri.hostname, uri.port]
627
637
 
628
- net_http_args.concat @proxy_args if
629
- @proxy_uri and not proxy_bypass? uri.host, uri.port
638
+ if @proxy_uri and not proxy_bypass? uri.hostname, uri.port then
639
+ net_http_args.concat @proxy_args
640
+ else
641
+ net_http_args.concat [nil, nil, nil, nil]
642
+ end
630
643
 
631
644
  connection = @pool.checkout net_http_args
632
645
 
@@ -643,6 +656,7 @@ class Net::HTTP::Persistent
643
656
  end
644
657
 
645
658
  http.read_timeout = @read_timeout if @read_timeout
659
+ http.write_timeout = @write_timeout if @write_timeout && http.respond_to?(:write_timeout=)
646
660
  http.keep_alive_timeout = @idle_timeout if @idle_timeout
647
661
 
648
662
  return yield connection
@@ -739,9 +753,8 @@ class Net::HTTP::Persistent
739
753
  # Is +req+ idempotent according to RFC 2616?
740
754
 
741
755
  def idempotent? req
742
- case req
743
- when Net::HTTP::Delete, Net::HTTP::Get, Net::HTTP::Head,
744
- Net::HTTP::Options, Net::HTTP::Put, Net::HTTP::Trace then
756
+ case req.method
757
+ when 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PUT', 'TRACE' then
745
758
  true
746
759
  end
747
760
  end
@@ -929,7 +942,7 @@ class Net::HTTP::Persistent
929
942
  # If a block is passed #request behaves like Net::HTTP#request (the body of
930
943
  # the response will not have been read).
931
944
  #
932
- # +req+ must be a Net::HTTPRequest subclass (see Net::HTTP for a list).
945
+ # +req+ must be a Net::HTTPGenericRequest subclass (see Net::HTTP for a list).
933
946
  #
934
947
  # If there is an error and the request is idempotent according to RFC 2616
935
948
  # it will be retried automatically.
@@ -20,6 +20,9 @@ class Net::HTTP::Persistent::Pool < ConnectionPool # :nodoc:
20
20
 
21
21
  if stack.empty?
22
22
  @available.push conn, connection_args: net_http_args
23
+
24
+ Thread.current[@key].delete(net_http_args)
25
+ Thread.current[@key] = nil if Thread.current[@key].empty?
23
26
  end
24
27
 
25
28
  nil
@@ -1,10 +1,20 @@
1
1
  class Net::HTTP::Persistent::TimedStackMulti < ConnectionPool::TimedStack # :nodoc:
2
2
 
3
+ ##
4
+ # Returns a new hash that has arrays for keys
5
+ #
6
+ # Using a class method to limit the bindings referenced by the hash's
7
+ # default_proc
8
+
9
+ def self.hash_of_arrays # :nodoc:
10
+ Hash.new { |h,k| h[k] = [] }
11
+ end
12
+
3
13
  def initialize(size = 0, &block)
4
14
  super
5
15
 
6
16
  @enqueued = 0
7
- @ques = Hash.new { |h, k| h[k] = [] }
17
+ @ques = self.class.hash_of_arrays
8
18
  @lru = {}
9
19
  @key = :"connection_args-#{object_id}"
10
20
  end
@@ -120,7 +120,7 @@ class TestNetHttpPersistent < Minitest::Test
120
120
  def basic_connection
121
121
  raise "#{@uri} is not HTTP" unless @uri.scheme.downcase == 'http'
122
122
 
123
- net_http_args = [@uri.host, @uri.port]
123
+ net_http_args = [@uri.host, @uri.port, nil, nil, nil, nil]
124
124
 
125
125
  connection = Net::HTTP::Persistent::Connection.allocate
126
126
  connection.ssl_generation = @http.ssl_generation
@@ -152,7 +152,7 @@ class TestNetHttpPersistent < Minitest::Test
152
152
  def ssl_connection
153
153
  raise "#{@uri} is not HTTPS" unless @uri.scheme.downcase == 'https'
154
154
 
155
- net_http_args = [@uri.host, @uri.port]
155
+ net_http_args = [@uri.host, @uri.port, nil, nil, nil, nil]
156
156
 
157
157
  connection = Net::HTTP::Persistent::Connection.allocate
158
158
  connection.ssl_generation = @http.ssl_generation
@@ -279,7 +279,7 @@ class TestNetHttpPersistent < Minitest::Test
279
279
  c
280
280
  end
281
281
 
282
- stored = @http.pool.checkout ['example.com', 80]
282
+ stored = @http.pool.checkout ['example.com', 80, nil, nil, nil, nil]
283
283
 
284
284
  assert_same used, stored
285
285
  end
@@ -395,6 +395,14 @@ class TestNetHttpPersistent < Minitest::Test
395
395
  end
396
396
  end
397
397
 
398
+ def test_connection_for_ipv6
399
+ uri = URI.parse 'https://[::1]/'
400
+
401
+ @http.connection_for uri do |c|
402
+ assert_equal '::1', c.http.address
403
+ end
404
+ end
405
+
398
406
  def test_connection_for_host_down
399
407
  c = basic_connection
400
408
  def (c.http).start; raise Errno::EHOSTDOWN end
@@ -538,6 +546,21 @@ class TestNetHttpPersistent < Minitest::Test
538
546
  assert stored
539
547
  end
540
548
 
549
+ def test_connection_for_no_proxy_from_env
550
+ ENV['http_proxy'] = 'proxy.example'
551
+ ENV['no_proxy'] = 'localhost, example.com,'
552
+ ENV['proxy_user'] = 'johndoe'
553
+ ENV['proxy_password'] = 'muffins'
554
+
555
+ http = Net::HTTP::Persistent.new proxy: :ENV
556
+
557
+ http.connection_for @uri do |c|
558
+ assert c.http.started?
559
+ refute c.http.proxy?
560
+ refute c.http.proxy_from_env?
561
+ end
562
+ end
563
+
541
564
  def test_connection_for_refused
542
565
  Net::HTTP.use_connect :refused_connect
543
566
 
@@ -728,7 +751,16 @@ class TestNetHttpPersistent < Minitest::Test
728
751
  assert @http.idempotent? Net::HTTP::Put.new '/'
729
752
  assert @http.idempotent? Net::HTTP::Trace.new '/'
730
753
 
754
+ assert @http.idempotent? Net::HTTPGenericRequest.new('DELETE', false, true, '/')
755
+ assert @http.idempotent? Net::HTTPGenericRequest.new('GET', false, true, '/')
756
+ assert @http.idempotent? Net::HTTPGenericRequest.new('HEAD', false, false, '/')
757
+ assert @http.idempotent? Net::HTTPGenericRequest.new('OPTIONS', false, false, '/')
758
+ assert @http.idempotent? Net::HTTPGenericRequest.new('PUT', true, true, '/')
759
+ assert @http.idempotent? Net::HTTPGenericRequest.new('TRACE', false, true, '/')
760
+
731
761
  refute @http.idempotent? Net::HTTP::Post.new '/'
762
+
763
+ refute @http.idempotent? Net::HTTPGenericRequest.new('POST', true, true, '/')
732
764
  end
733
765
 
734
766
  def test_normalize_uri
@@ -751,7 +783,7 @@ class TestNetHttpPersistent < Minitest::Test
751
783
  skip 'net-http-pipeline not installed' unless defined?(Net::HTTP::Pipeline)
752
784
 
753
785
  cached = basic_connection
754
- cached.start
786
+ cached.http.start
755
787
 
756
788
  requests = [
757
789
  Net::HTTP::Get.new((@uri + '1').request_uri),
metadata CHANGED
@@ -1,14 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: net-http-persistent
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
8
8
  autorequire:
9
9
  b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EVu1y+fPhNAu6OTMgVtgkijEuA9d4OQ2xusF/YKWkaVkjrdHcDAEaquxYUKrswxM
28
+ DohqfAYWGDt2dmCWfRWTsBLm3p3R0mwKe8uOy4gSwcvG5SG57oSZoxrAN9CgsJoR
29
+ P+3YOaiDtZ7g4lYXhpJrMooDnoWr4TPbGIVuq0xfPlFinjBH0o1W+LfGS+3aCN6b
30
+ jT8g+1iKSQKJYA==
31
+ -----END CERTIFICATE-----
32
+ date: 2019-07-25 00:00:00.000000000 Z
12
33
  dependencies:
13
34
  - !ruby/object:Gem::Dependency
14
35
  name: connection_pool
@@ -38,6 +59,40 @@ dependencies:
38
59
  - - "~>"
39
60
  - !ruby/object:Gem::Version
40
61
  version: '5.11'
62
+ - !ruby/object:Gem::Dependency
63
+ name: hoe-bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.5'
76
+ - !ruby/object:Gem::Dependency
77
+ name: hoe-travis
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.4'
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 1.4.1
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '1.4'
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 1.4.1
41
96
  - !ruby/object:Gem::Dependency
42
97
  name: rdoc
43
98
  requirement: !ruby/object:Gem::Requirement
@@ -95,6 +150,7 @@ files:
95
150
  - ".autotest"
96
151
  - ".gemtest"
97
152
  - ".travis.yml"
153
+ - Gemfile
98
154
  - History.txt
99
155
  - Manifest.txt
100
156
  - README.rdoc
@@ -126,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
182
  - !ruby/object:Gem::Version
127
183
  version: '0'
128
184
  requirements: []
129
- rubygems_version: 3.0.1
185
+ rubygems_version: 3.0.3
130
186
  signing_key:
131
187
  specification_version: 4
132
188
  summary: Manages persistent connections using Net::HTTP plus a speed fix for Ruby
@@ -0,0 +1,2 @@
1
+ x�L��)��0�嫗f[f+K�Ն�ʺ�,&��L6�9�4�m(��hρ�X�O`�w�/���OX��S�#y�j6c(ܜ6�qB��k��_��W;��D�6������*�ϴ��mV_�+��R\���H@
2
+ ��O�+)#� tB]�/�����崯���[���1x#w�M׳$�W�>�nb���}8�O�