1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[bundler/bundler] net-http-persistent 3.1.0 has been released

https://github.com/bundler/bundler/commit/ffb7d6fa53
This commit is contained in:
David Rodríguez 2019-07-25 08:45:39 +02:00 committed by Hiroshi SHIBATA
parent fcb58f65b1
commit dab944e6ca
No known key found for this signature in database
GPG key ID: F9CF13417264FAC2
3 changed files with 31 additions and 9 deletions

View file

@ -211,7 +211,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
##
# The version of Bundler::Persistent::Net::HTTP::Persistent you are using
VERSION = '3.0.1'
VERSION = '3.1.0'
##
# Exceptions rescued for automatic retry on ruby 2.0.0. This overlaps with
@ -410,6 +410,11 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_accessor :read_timeout
##
# Seconds to wait until writing one block. See Net::HTTP#write_timeout
attr_accessor :write_timeout
##
# By default SSL sessions are reused to avoid extra SSL handshakes. Set
# this to false if you have problems communicating with an HTTPS server
@ -534,6 +539,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
@keep_alive = 30
@open_timeout = nil
@read_timeout = nil
@write_timeout = nil
@idle_timeout = 5
@max_requests = nil
@socket_options = []
@ -627,10 +633,13 @@ class Bundler::Persistent::Net::HTTP::Persistent
def connection_for uri
use_ssl = uri.scheme.downcase == 'https'
net_http_args = [uri.host, uri.port]
net_http_args = [uri.hostname, uri.port]
net_http_args.concat @proxy_args if
@proxy_uri and not proxy_bypass? uri.host, uri.port
if @proxy_uri and not proxy_bypass? uri.hostname, uri.port then
net_http_args.concat @proxy_args
else
net_http_args.concat [nil, nil, nil, nil]
end
connection = @pool.checkout net_http_args
@ -647,6 +656,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
http.read_timeout = @read_timeout if @read_timeout
http.write_timeout = @write_timeout if @write_timeout && http.respond_to?(:write_timeout=)
http.keep_alive_timeout = @idle_timeout if @idle_timeout
return yield connection
@ -743,9 +753,8 @@ class Bundler::Persistent::Net::HTTP::Persistent
# Is +req+ idempotent according to RFC 2616?
def idempotent? req
case req
when Net::HTTP::Delete, Net::HTTP::Get, Net::HTTP::Head,
Net::HTTP::Options, Net::HTTP::Put, Net::HTTP::Trace then
case req.method
when 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PUT', 'TRACE' then
true
end
end
@ -933,7 +942,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
# If a block is passed #request behaves like Net::HTTP#request (the body of
# the response will not have been read).
#
# +req+ must be a Net::HTTPRequest subclass (see Net::HTTP for a list).
# +req+ must be a Net::HTTPGenericRequest subclass (see Net::HTTP for a list).
#
# If there is an error and the request is idempotent according to RFC 2616
# it will be retried automatically.

View file

@ -20,6 +20,9 @@ class Bundler::Persistent::Net::HTTP::Persistent::Pool < Bundler::ConnectionPool
if stack.empty?
@available.push conn, connection_args: net_http_args
Thread.current[@key].delete(net_http_args)
Thread.current[@key] = nil if Thread.current[@key].empty?
end
nil

View file

@ -1,10 +1,20 @@
class Bundler::Persistent::Net::HTTP::Persistent::TimedStackMulti < Bundler::ConnectionPool::TimedStack # :nodoc:
##
# Returns a new hash that has arrays for keys
#
# Using a class method to limit the bindings referenced by the hash's
# default_proc
def self.hash_of_arrays # :nodoc:
Hash.new { |h,k| h[k] = [] }
end
def initialize(size = 0, &block)
super
@enqueued = 0
@ques = Hash.new { |h, k| h[k] = [] }
@ques = self.class.hash_of_arrays
@lru = {}
@key = :"connection_args-#{object_id}"
end