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
ffb7d6fa53
This commit is contained in:
parent
fcb58f65b1
commit
dab944e6ca
3 changed files with 31 additions and 9 deletions
|
@ -211,7 +211,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
|
||||||
##
|
##
|
||||||
# The version of Bundler::Persistent::Net::HTTP::Persistent you are using
|
# 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
|
# 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
|
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
|
# By default SSL sessions are reused to avoid extra SSL handshakes. Set
|
||||||
# this to false if you have problems communicating with an HTTPS server
|
# 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
|
@keep_alive = 30
|
||||||
@open_timeout = nil
|
@open_timeout = nil
|
||||||
@read_timeout = nil
|
@read_timeout = nil
|
||||||
|
@write_timeout = nil
|
||||||
@idle_timeout = 5
|
@idle_timeout = 5
|
||||||
@max_requests = nil
|
@max_requests = nil
|
||||||
@socket_options = []
|
@socket_options = []
|
||||||
|
@ -627,10 +633,13 @@ class Bundler::Persistent::Net::HTTP::Persistent
|
||||||
def connection_for uri
|
def connection_for uri
|
||||||
use_ssl = uri.scheme.downcase == 'https'
|
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
|
if @proxy_uri and not proxy_bypass? uri.hostname, uri.port then
|
||||||
@proxy_uri and not proxy_bypass? uri.host, uri.port
|
net_http_args.concat @proxy_args
|
||||||
|
else
|
||||||
|
net_http_args.concat [nil, nil, nil, nil]
|
||||||
|
end
|
||||||
|
|
||||||
connection = @pool.checkout net_http_args
|
connection = @pool.checkout net_http_args
|
||||||
|
|
||||||
|
@ -647,6 +656,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
|
||||||
end
|
end
|
||||||
|
|
||||||
http.read_timeout = @read_timeout if @read_timeout
|
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
|
http.keep_alive_timeout = @idle_timeout if @idle_timeout
|
||||||
|
|
||||||
return yield connection
|
return yield connection
|
||||||
|
@ -743,9 +753,8 @@ class Bundler::Persistent::Net::HTTP::Persistent
|
||||||
# Is +req+ idempotent according to RFC 2616?
|
# Is +req+ idempotent according to RFC 2616?
|
||||||
|
|
||||||
def idempotent? req
|
def idempotent? req
|
||||||
case req
|
case req.method
|
||||||
when Net::HTTP::Delete, Net::HTTP::Get, Net::HTTP::Head,
|
when 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PUT', 'TRACE' then
|
||||||
Net::HTTP::Options, Net::HTTP::Put, Net::HTTP::Trace then
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
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
|
# If a block is passed #request behaves like Net::HTTP#request (the body of
|
||||||
# the response will not have been read).
|
# 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
|
# If there is an error and the request is idempotent according to RFC 2616
|
||||||
# it will be retried automatically.
|
# it will be retried automatically.
|
||||||
|
|
|
@ -20,6 +20,9 @@ class Bundler::Persistent::Net::HTTP::Persistent::Pool < Bundler::ConnectionPool
|
||||||
|
|
||||||
if stack.empty?
|
if stack.empty?
|
||||||
@available.push conn, connection_args: net_http_args
|
@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
|
end
|
||||||
|
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -1,10 +1,20 @@
|
||||||
class Bundler::Persistent::Net::HTTP::Persistent::TimedStackMulti < Bundler::ConnectionPool::TimedStack # :nodoc:
|
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)
|
def initialize(size = 0, &block)
|
||||||
super
|
super
|
||||||
|
|
||||||
@enqueued = 0
|
@enqueued = 0
|
||||||
@ques = Hash.new { |h, k| h[k] = [] }
|
@ques = self.class.hash_of_arrays
|
||||||
@lru = {}
|
@lru = {}
|
||||||
@key = :"connection_args-#{object_id}"
|
@key = :"connection_args-#{object_id}"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue