Skip to content

Commit f855bcc

Browse files
committed
Applied rake vendor:install
1 parent cc3d304 commit f855bcc

3 files changed

Lines changed: 96 additions & 63 deletions

File tree

lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb

Lines changed: 78 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@
4343
# # perform the POST, the Gem::URI is always required
4444
# response http.request post_uri, post
4545
#
46-
# Note that for GET, HEAD and other requests that do not have a body you want
47-
# to use Gem::URI#request_uri not Gem::URI#path. The request_uri contains the query
48-
# params which are sent in the body for other requests.
46+
# ⚠ Note that for GET, HEAD and other requests that do not have a body,
47+
# it uses Gem::URI#request_uri as default to send query params
4948
#
5049
# == TLS/SSL
5150
#
@@ -61,6 +60,7 @@
6160
# #ca_path :: Directory with certificate-authorities
6261
# #cert_store :: An SSL certificate store
6362
# #ciphers :: List of SSl ciphers allowed
63+
# #extra_chain_cert :: Extra certificates to be added to the certificate chain
6464
# #private_key :: The client's SSL private key
6565
# #reuse_ssl_sessions :: Reuse a previously opened SSL session for a new
6666
# connection
@@ -177,7 +177,7 @@ class Gem::Net::HTTP::Persistent
177177
##
178178
# The version of Gem::Net::HTTP::Persistent you are using
179179

180-
VERSION = '4.0.4'
180+
VERSION = '4.0.6'
181181

182182
##
183183
# Error class for errors raised by Gem::Net::HTTP::Persistent. Various
@@ -268,6 +268,11 @@ def self.detect_idle_timeout uri, max = 10
268268

269269
attr_reader :ciphers
270270

271+
##
272+
# Extra certificates to be added to the certificate chain
273+
274+
attr_reader :extra_chain_cert
275+
271276
##
272277
# Sends debug_output to this IO via Gem::Net::HTTP#set_debug_output.
273278
#
@@ -588,6 +593,21 @@ def ciphers= ciphers
588593
reconnect_ssl
589594
end
590595

596+
if Gem::Net::HTTP.method_defined?(:extra_chain_cert=)
597+
##
598+
# Extra certificates to be added to the certificate chain.
599+
# It is only supported starting from Gem::Net::HTTP version 0.1.1
600+
def extra_chain_cert= extra_chain_cert
601+
@extra_chain_cert = extra_chain_cert
602+
603+
reconnect_ssl
604+
end
605+
else
606+
def extra_chain_cert= _extra_chain_cert
607+
raise "extra_chain_cert= is not supported by this version of Gem::Net::HTTP"
608+
end
609+
end
610+
591611
##
592612
# Creates a new connection for +uri+
593613

@@ -606,47 +626,49 @@ def connection_for uri
606626

607627
connection = @pool.checkout net_http_args
608628

609-
http = connection.http
629+
begin
630+
http = connection.http
610631

611-
connection.ressl @ssl_generation if
612-
connection.ssl_generation != @ssl_generation
632+
connection.ressl @ssl_generation if
633+
connection.ssl_generation != @ssl_generation
613634

614-
if not http.started? then
615-
ssl http if use_ssl
616-
start http
617-
elsif expired? connection then
618-
reset connection
619-
end
635+
if not http.started? then
636+
ssl http if use_ssl
637+
start http
638+
elsif expired? connection then
639+
reset connection
640+
end
620641

621-
http.keep_alive_timeout = @idle_timeout if @idle_timeout
622-
http.max_retries = @max_retries if http.respond_to?(:max_retries=)
623-
http.read_timeout = @read_timeout if @read_timeout
624-
http.write_timeout = @write_timeout if
625-
@write_timeout && http.respond_to?(:write_timeout=)
642+
http.keep_alive_timeout = @idle_timeout if @idle_timeout
643+
http.max_retries = @max_retries if http.respond_to?(:max_retries=)
644+
http.read_timeout = @read_timeout if @read_timeout
645+
http.write_timeout = @write_timeout if
646+
@write_timeout && http.respond_to?(:write_timeout=)
647+
648+
return yield connection
649+
rescue Errno::ECONNREFUSED
650+
if http.proxy?
651+
address = http.proxy_address
652+
port = http.proxy_port
653+
else
654+
address = http.address
655+
port = http.port
656+
end
626657

627-
return yield connection
628-
rescue Errno::ECONNREFUSED
629-
if http.proxy?
630-
address = http.proxy_address
631-
port = http.proxy_port
632-
else
633-
address = http.address
634-
port = http.port
635-
end
658+
raise Error, "connection refused: #{address}:#{port}"
659+
rescue Errno::EHOSTDOWN
660+
if http.proxy?
661+
address = http.proxy_address
662+
port = http.proxy_port
663+
else
664+
address = http.address
665+
port = http.port
666+
end
636667

637-
raise Error, "connection refused: #{address}:#{port}"
638-
rescue Errno::EHOSTDOWN
639-
if http.proxy?
640-
address = http.proxy_address
641-
port = http.proxy_port
642-
else
643-
address = http.address
644-
port = http.port
668+
raise Error, "host down: #{address}:#{port}"
669+
ensure
670+
@pool.checkin net_http_args
645671
end
646-
647-
raise Error, "host down: #{address}:#{port}"
648-
ensure
649-
@pool.checkin net_http_args
650672
end
651673

652674
##
@@ -954,7 +976,8 @@ def request_setup req_or_uri # :nodoc:
954976
end
955977

956978
##
957-
# Shuts down all connections
979+
# Shuts down all connections. Attempting to checkout a connection after
980+
# shutdown will raise an error.
958981
#
959982
# *NOTE*: Calling shutdown for can be dangerous!
960983
#
@@ -965,6 +988,17 @@ def shutdown
965988
@pool.shutdown { |http| http.finish }
966989
end
967990

991+
##
992+
# Discard all existing connections. Subsequent checkouts will create
993+
# new connections as needed.
994+
#
995+
# If any thread is still using a connection it may cause an error! Call
996+
# #reload when you are completely done making requests!
997+
998+
def reload
999+
@pool.reload { |http| http.finish }
1000+
end
1001+
9681002
##
9691003
# Enables SSL on +connection+
9701004

@@ -1022,6 +1056,10 @@ def ssl connection
10221056
connection.key = @private_key
10231057
end
10241058

1059+
if defined?(@extra_chain_cert) and @extra_chain_cert
1060+
connection.extra_chain_cert = @extra_chain_cert
1061+
end
1062+
10251063
connection.cert_store = if @cert_store then
10261064
@cert_store
10271065
else

lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def try_create options = {} # :nodoc:
6363
if @created >= @max && @enqueued >= 1
6464
oldest, = @lru.first
6565
@lru.delete oldest
66-
@ques[oldest].pop
66+
connection = @ques[oldest].pop
67+
connection.close if connection.respond_to?(:close)
6768

6869
@created -= 1
6970
end

lib/rubygems/vendor/net-http/lib/net/http.rb

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class HTTPHeaderSyntaxError < StandardError; end
4646
# == Strategies
4747
#
4848
# - If you will make only a few GET requests,
49-
# consider using {OpenURI}[rdoc-ref:OpenURI].
49+
# consider using {OpenURI}[https://docs.ruby-lang.org/en/master/OpenURI.html].
5050
# - If you will make only a few requests of all kinds,
5151
# consider using the various singleton convenience methods in this class.
5252
# Each of the following methods automatically starts and finishes
@@ -108,7 +108,7 @@ class HTTPHeaderSyntaxError < StandardError; end
108108
# It consists of some or all of: scheme, hostname, path, query, and fragment;
109109
# see {URI syntax}[https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax].
110110
#
111-
# A Ruby {Gem::URI::Generic}[rdoc-ref:Gem::URI::Generic] object
111+
# A Ruby {Gem::URI::Generic}[https://docs.ruby-lang.org/en/master/Gem/URI/Generic.html] object
112112
# represents an internet URI.
113113
# It provides, among others, methods
114114
# +scheme+, +hostname+, +path+, +query+, and +fragment+.
@@ -460,7 +460,7 @@ class HTTPHeaderSyntaxError < StandardError; end
460460
#
461461
# First, what's elsewhere. Class Gem::Net::HTTP:
462462
#
463-
# - Inherits from {class Object}[rdoc-ref:Object@What-27s+Here].
463+
# - Inherits from {class Object}[https://docs.ruby-lang.org/en/master/Object.html#class-Object-label-What-27s+Here].
464464
#
465465
# This is a categorized summary of methods and attributes.
466466
#
@@ -475,8 +475,7 @@ class HTTPHeaderSyntaxError < StandardError; end
475475
#
476476
# - {::start}[rdoc-ref:Gem::Net::HTTP.start]:
477477
# Begins a new session in a new \Gem::Net::HTTP object.
478-
# - {#started?}[rdoc-ref:Gem::Net::HTTP#started?]
479-
# (aliased as {#active?}[rdoc-ref:Gem::Net::HTTP#active?]):
478+
# - {#started?}[rdoc-ref:Gem::Net::HTTP#started?]:
480479
# Returns whether in a session.
481480
# - {#finish}[rdoc-ref:Gem::Net::HTTP#finish]:
482481
# Ends an active session.
@@ -556,18 +555,15 @@ class HTTPHeaderSyntaxError < StandardError; end
556555
# Sends a PUT request and returns a response object.
557556
# - {#request}[rdoc-ref:Gem::Net::HTTP#request]:
558557
# Sends a request and returns a response object.
559-
# - {#request_get}[rdoc-ref:Gem::Net::HTTP#request_get]
560-
# (aliased as {#get2}[rdoc-ref:Gem::Net::HTTP#get2]):
558+
# - {#request_get}[rdoc-ref:Gem::Net::HTTP#request_get]:
561559
# Sends a GET request and forms a response object;
562560
# if a block given, calls the block with the object,
563561
# otherwise returns the object.
564-
# - {#request_head}[rdoc-ref:Gem::Net::HTTP#request_head]
565-
# (aliased as {#head2}[rdoc-ref:Gem::Net::HTTP#head2]):
562+
# - {#request_head}[rdoc-ref:Gem::Net::HTTP#request_head]:
566563
# Sends a HEAD request and forms a response object;
567564
# if a block given, calls the block with the object,
568565
# otherwise returns the object.
569-
# - {#request_post}[rdoc-ref:Gem::Net::HTTP#request_post]
570-
# (aliased as {#post2}[rdoc-ref:Gem::Net::HTTP#post2]):
566+
# - {#request_post}[rdoc-ref:Gem::Net::HTTP#request_post]:
571567
# Sends a POST request and forms a response object;
572568
# if a block given, calls the block with the object,
573569
# otherwise returns the object.
@@ -605,8 +601,7 @@ class HTTPHeaderSyntaxError < StandardError; end
605601
# Returns whether +self+ is a proxy class.
606602
# - {#proxy?}[rdoc-ref:Gem::Net::HTTP#proxy?]:
607603
# Returns whether +self+ has a proxy.
608-
# - {#proxy_address}[rdoc-ref:Gem::Net::HTTP#proxy_address]
609-
# (aliased as {#proxyaddr}[rdoc-ref:Gem::Net::HTTP#proxyaddr]):
604+
# - {#proxy_address}[rdoc-ref:Gem::Net::HTTP#proxy_address]:
610605
# Returns the proxy address.
611606
# - {#proxy_from_env?}[rdoc-ref:Gem::Net::HTTP#proxy_from_env?]:
612607
# Returns whether the proxy is taken from an environment variable.
@@ -718,8 +713,7 @@ class HTTPHeaderSyntaxError < StandardError; end
718713
# === \HTTP Version
719714
#
720715
# - {::version_1_2?}[rdoc-ref:Gem::Net::HTTP.version_1_2?]
721-
# (aliased as {::is_version_1_2?}[rdoc-ref:Gem::Net::HTTP.is_version_1_2?]
722-
# and {::version_1_2}[rdoc-ref:Gem::Net::HTTP.version_1_2]):
716+
# (aliased as {::version_1_2}[rdoc-ref:Gem::Net::HTTP.version_1_2]):
723717
# Returns true; retained for compatibility.
724718
#
725719
# === Debugging
@@ -1293,7 +1287,7 @@ def set_debug_output(output)
12931287
# - The name of an encoding.
12941288
# - An alias for an encoding name.
12951289
#
1296-
# See {Encoding}[rdoc-ref:Encoding].
1290+
# See {Encoding}[https://docs.ruby-lang.org/en/master/Encoding.html].
12971291
#
12981292
# Examples:
12991293
#
@@ -1552,11 +1546,11 @@ def use_ssl=(flag)
15521546
attr_accessor :cert_store
15531547

15541548
# Sets or returns the available SSL ciphers.
1555-
# See {OpenSSL::SSL::SSLContext#ciphers=}[rdoc-ref:OpenSSL::SSL::SSLContext#ciphers-3D].
1549+
# See {OpenSSL::SSL::SSLContext#ciphers=}[OpenSSL::SSL::SSL::Context#ciphers=].
15561550
attr_accessor :ciphers
15571551

15581552
# Sets or returns the extra X509 certificates to be added to the certificate chain.
1559-
# See {OpenSSL::SSL::SSLContext#add_certificate}[rdoc-ref:OpenSSL::SSL::SSLContext#add_certificate].
1553+
# See {OpenSSL::SSL::SSLContext#add_certificate}[OpenSSL::SSL::SSL::Context#add_certificate].
15601554
attr_accessor :extra_chain_cert
15611555

15621556
# Sets or returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
@@ -1566,15 +1560,15 @@ def use_ssl=(flag)
15661560
attr_accessor :ssl_timeout
15671561

15681562
# Sets or returns the SSL version.
1569-
# See {OpenSSL::SSL::SSLContext#ssl_version=}[rdoc-ref:OpenSSL::SSL::SSLContext#ssl_version-3D].
1563+
# See {OpenSSL::SSL::SSLContext#ssl_version=}[OpenSSL::SSL::SSL::Context#ssl_version=].
15701564
attr_accessor :ssl_version
15711565

15721566
# Sets or returns the minimum SSL version.
1573-
# See {OpenSSL::SSL::SSLContext#min_version=}[rdoc-ref:OpenSSL::SSL::SSLContext#min_version-3D].
1567+
# See {OpenSSL::SSL::SSLContext#min_version=}[OpenSSL::SSL::SSL::Context#min_version=].
15741568
attr_accessor :min_version
15751569

15761570
# Sets or returns the maximum SSL version.
1577-
# See {OpenSSL::SSL::SSLContext#max_version=}[rdoc-ref:OpenSSL::SSL::SSLContext#max_version-3D].
1571+
# See {OpenSSL::SSL::SSLContext#max_version=}[OpenSSL::SSL::SSL::Context#max_version=].
15781572
attr_accessor :max_version
15791573

15801574
# Sets or returns the callback for the server certification verification.
@@ -1590,7 +1584,7 @@ def use_ssl=(flag)
15901584

15911585
# Sets or returns whether to verify that the server certificate is valid
15921586
# for the hostname.
1593-
# See {OpenSSL::SSL::SSLContext#verify_hostname=}[rdoc-ref:OpenSSL::SSL::SSLContext#attribute-i-verify_mode].
1587+
# See {OpenSSL::SSL::SSLContext#verify_hostname=}[OpenSSL::SSL::SSL::Context#verify_hostname=].
15941588
attr_accessor :verify_hostname
15951589

15961590
# Returns the X509 certificate chain (an array of strings)

0 commit comments

Comments
 (0)