Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/language/box.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ruby Box - Ruby's in-process separation of Classes and Modules

Ruby Box is designed to provide separated spaces in a Ruby process, to isolate application codes, libraries and monkey patches.
Ruby Box is designed to provide separated spaces in a Ruby process, to isolate application code, libraries and monkey patches.

## Known issues

Expand Down
5 changes: 0 additions & 5 deletions include/ruby/internal/core/rdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,6 @@ VALUE rb_data_object_wrap(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_D
*/
VALUE rb_data_object_zalloc(VALUE klass, size_t size, RUBY_DATA_FUNC dmark, RUBY_DATA_FUNC dfree);

/**
* @private
* Documented in include/ruby/internal/globals.h
*/
RUBY_EXTERN VALUE rb_cObject;
RBIMPL_SYMBOL_EXPORT_END()

/**
Expand Down
3 changes: 3 additions & 0 deletions lib/bundler/vendor/connection_pool/lib/connection_pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ def initialize(options = {}, &block)
end

def with(options = {})
# We need to manage exception handling manually here in order
# to work correctly with `Gem::Timeout.timeout` and `Thread#raise`.
# Otherwise an interrupted Thread can leak connections.
Thread.handle_interrupt(Exception => :never) do
conn = checkout(options)
begin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ def push(obj, options = {})
# immediately returned. If no connection is available within the given
# timeout a Bundler::ConnectionPool::TimeoutError is raised.
#
# +:timeout+ is the only checked entry in +options+ and is preferred over
# the +timeout+ argument (which will be removed in a future release). Other
# options may be used by subclasses that extend TimedStack.
# @option options [Float] :timeout (0.5) Wait this many seconds for an available entry
# @option options [Class] :exception (Bundler::ConnectionPool::TimeoutError) Exception class to raise
# if an entry was not available within the timeout period. Use `exception: false` to return nil.
#
# The +timeout+ argument will be removed in 3.0.
# Other options may be used by subclasses that extend TimedStack.
def pop(timeout = 0.5, options = {})
options, timeout = timeout, 0.5 if Hash === timeout
timeout = options.fetch :timeout, timeout
Expand All @@ -73,7 +76,14 @@ def pop(timeout = 0.5, options = {})
return connection if connection

to_wait = deadline - current_time
raise Bundler::ConnectionPool::TimeoutError, "Waited #{timeout} sec, #{length}/#{@max} available" if to_wait <= 0
if to_wait <= 0
exc = options.fetch(:exception, Bundler::ConnectionPool::TimeoutError)
if exc
raise Bundler::ConnectionPool::TimeoutError, "Waited #{timeout} sec, #{length}/#{@max} available"
else
return nil
end
end
@resource.wait(@mutex, to_wait)
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class Bundler::ConnectionPool
VERSION = "2.5.4"
VERSION = "2.5.5"
end
83 changes: 58 additions & 25 deletions lib/rubygems/vendor/net-http/lib/net/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ class HTTPHeaderSyntaxError < StandardError; end
class HTTP < Protocol

# :stopdoc:
VERSION = "0.7.0"
VERSION = "0.9.1"
HTTPVersion = '1.1'
begin
require 'zlib'
Expand Down Expand Up @@ -1179,6 +1179,7 @@ def initialize(address, port = nil) # :nodoc:
@debug_output = options[:debug_output]
@response_body_encoding = options[:response_body_encoding]
@ignore_eof = options[:ignore_eof]
@tcpsocket_supports_open_timeout = nil

@proxy_from_env = false
@proxy_uri = nil
Expand Down Expand Up @@ -1321,6 +1322,9 @@ def response_body_encoding=(value)
# Sets the proxy password;
# see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
attr_writer :proxy_pass

# Sets whether the proxy uses SSL;
# see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
attr_writer :proxy_use_ssl

# Returns the IP address for the connection.
Expand Down Expand Up @@ -1527,7 +1531,7 @@ def use_ssl=(flag)
:verify_depth,
:verify_mode,
:verify_hostname,
] # :nodoc:
].freeze # :nodoc:

SSL_IVNAMES = SSL_ATTRIBUTES.map { |a| "@#{a}".to_sym }.freeze # :nodoc:

Expand Down Expand Up @@ -1632,6 +1636,21 @@ def start # :yield: http
self
end

# Finishes the \HTTP session:
#
# http = Gem::Net::HTTP.new(hostname)
# http.start
# http.started? # => true
# http.finish # => nil
# http.started? # => false
#
# Raises IOError if not in a session.
def finish
raise IOError, 'HTTP session not yet started' unless started?
do_finish
end

# :stopdoc:
def do_start
connect
@started = true
Expand All @@ -1654,14 +1673,15 @@ def connect
end

debug "opening connection to #{conn_addr}:#{conn_port}..."
s = Gem::Timeout.timeout(@open_timeout, Gem::Net::OpenTimeout) {
begin
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
rescue => e
raise e, "Failed to open TCP connection to " +
"#{conn_addr}:#{conn_port} (#{e.message})"
begin
s = timeouted_connect(conn_addr, conn_port)
rescue => e
if (defined?(IO::TimeoutError) && e.is_a?(IO::TimeoutError)) || e.is_a?(Errno::ETIMEDOUT) # for compatibility with previous versions
e = Gem::Net::OpenTimeout.new(e)
end
}
raise e, "Failed to open TCP connection to " +
"#{conn_addr}:#{conn_port} (#{e.message})"
end
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
debug "opened"
if use_ssl?
Expand Down Expand Up @@ -1754,23 +1774,30 @@ def connect
end
private :connect

def on_connect
tcp_socket_parameters = TCPSocket.instance_method(:initialize).parameters
TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT = if tcp_socket_parameters != [[:rest]]
tcp_socket_parameters.include?([:key, :open_timeout])
else
# Use Socket.tcp to find out since there is no parameters information for TCPSocket#initialize
# See discussion in https://github.com/ruby/net-http/pull/224
Socket.method(:tcp).parameters.include?([:key, :open_timeout])
end
private :on_connect
private_constant :TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT

# Finishes the \HTTP session:
#
# http = Gem::Net::HTTP.new(hostname)
# http.start
# http.started? # => true
# http.finish # => nil
# http.started? # => false
#
# Raises IOError if not in a session.
def finish
raise IOError, 'HTTP session not yet started' unless started?
do_finish
def timeouted_connect(conn_addr, conn_port)
if TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port, open_timeout: @open_timeout)
else
Gem::Timeout.timeout(@open_timeout, Gem::Net::OpenTimeout) {
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
}
end
end
private :timeouted_connect

def on_connect
end
private :on_connect

def do_finish
@started = false
Expand Down Expand Up @@ -1821,6 +1848,8 @@ def HTTP.Proxy(p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_use_ss
}
end

# :startdoc:

class << HTTP
# Returns true if self is a class which was created by HTTP::Proxy.
def proxy_class?
Expand Down Expand Up @@ -1915,6 +1944,7 @@ def proxy_pass
alias proxyport proxy_port #:nodoc: obsolete

private
# :stopdoc:

def unescape(value)
require 'cgi/escape'
Expand Down Expand Up @@ -1943,6 +1973,7 @@ def edit_path(path)
path
end
end
# :startdoc:

#
# HTTP operations
Expand Down Expand Up @@ -2397,7 +2428,9 @@ def send_entity(path, data, initheader, dest, type, &block)
res
end

IDEMPOTENT_METHODS_ = %w/GET HEAD PUT DELETE OPTIONS TRACE/ # :nodoc:
# :stopdoc:

IDEMPOTENT_METHODS_ = %w/GET HEAD PUT DELETE OPTIONS TRACE/.freeze # :nodoc:

def transport_request(req)
count = 0
Expand Down Expand Up @@ -2554,7 +2587,7 @@ def debug(msg)
alias_method :D, :debug
end

# for backward compatibility until Ruby 3.5
# for backward compatibility until Ruby 4.0
# https://bugs.ruby-lang.org/issues/20900
# https://github.com/bblimke/webmock/pull/1081
HTTPSession = HTTP
Expand Down
3 changes: 2 additions & 1 deletion lib/rubygems/vendor/net-http/lib/net/http/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Gem::Net
# Gem::Net::HTTP exception class.
# You cannot use Gem::Net::HTTPExceptions directly; instead, you must use
# its subclasses.
module HTTPExceptions
module HTTPExceptions # :nodoc:
def initialize(msg, res) #:nodoc:
super msg
@response = res
Expand All @@ -12,6 +12,7 @@ def initialize(msg, res) #:nodoc:
alias data response #:nodoc: obsolete
end

# :stopdoc:
class HTTPError < ProtocolError
include HTTPExceptions
end
Expand Down
11 changes: 5 additions & 6 deletions lib/rubygems/vendor/net-http/lib/net/http/generic_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@ def initialize(m, reqbody, resbody, uri_or_path, initheader = nil) # :nodoc:

if Gem::URI === uri_or_path then
raise ArgumentError, "not an HTTP Gem::URI" unless Gem::URI::HTTP === uri_or_path
hostname = uri_or_path.hostname
hostname = uri_or_path.host
raise ArgumentError, "no host component for Gem::URI" unless (hostname && hostname.length > 0)
@uri = uri_or_path.dup
host = @uri.hostname.dup
host << ":" << @uri.port.to_s if @uri.port != @uri.default_port
@path = uri_or_path.request_uri
raise ArgumentError, "no HTTP request path given" unless @path
else
@uri = nil
host = nil
raise ArgumentError, "no HTTP request path given" unless uri_or_path
raise ArgumentError, "HTTP request path is empty" if uri_or_path.empty?
@path = uri_or_path.dup
Expand All @@ -51,7 +48,7 @@ def initialize(m, reqbody, resbody, uri_or_path, initheader = nil) # :nodoc:
initialize_http_header initheader
self['Accept'] ||= '*/*'
self['User-Agent'] ||= 'Ruby'
self['Host'] ||= host if host
self['Host'] ||= @uri.authority if @uri
@body = nil
@body_stream = nil
@body_data = nil
Expand Down Expand Up @@ -245,7 +242,7 @@ def update_uri(addr, port, ssl) # :nodoc: internal use only
end

if host = self['host']
host.sub!(/:.*/m, '')
host = Gem::URI.parse("//#{host}").host # Remove a port component from the existing Host header
elsif host = @uri.host
else
host = addr
Expand All @@ -264,6 +261,8 @@ def update_uri(addr, port, ssl) # :nodoc: internal use only

private

# :stopdoc:

class Chunker #:nodoc:
def initialize(sock)
@sock = sock
Expand Down
12 changes: 8 additions & 4 deletions lib/rubygems/vendor/net-http/lib/net/http/header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@
# - #each_value: Passes each string field value to the block.
#
module Gem::Net::HTTPHeader
# The maximum length of HTTP header keys.
MAX_KEY_LENGTH = 1024
# The maximum length of HTTP header values.
MAX_FIELD_LENGTH = 65536

def initialize_http_header(initheader) #:nodoc:
Expand Down Expand Up @@ -267,6 +269,7 @@ def add_field(key, val)
end
end

# :stopdoc:
private def set_field(key, val)
case val
when Enumerable
Expand Down Expand Up @@ -294,6 +297,7 @@ def add_field(key, val)
ary.push val
end
end
# :startdoc:

# Returns the array field value for the given +key+,
# or +nil+ if there is no such field;
Expand Down Expand Up @@ -490,7 +494,7 @@ def each_capitalized

alias canonical_each each_capitalized

def capitalize(name)
def capitalize(name) # :nodoc:
name.to_s.split('-'.freeze).map {|s| s.capitalize }.join('-'.freeze)
end
private :capitalize
Expand Down Expand Up @@ -957,20 +961,20 @@ def proxy_basic_auth(account, password)
@header['proxy-authorization'] = [basic_encode(account, password)]
end

def basic_encode(account, password)
def basic_encode(account, password) # :nodoc:
'Basic ' + ["#{account}:#{password}"].pack('m0')
end
private :basic_encode

# Returns whether the HTTP session is to be closed.
# Returns whether the HTTP session is to be closed.
def connection_close?
token = /(?:\A|,)\s*close\s*(?:\z|,)/i
@header['connection']&.grep(token) {return true}
@header['proxy-connection']&.grep(token) {return true}
false
end

# Returns whether the HTTP session is to be kept alive.
# Returns whether the HTTP session is to be kept alive.
def connection_keep_alive?
token = /(?:\A|,)\s*keep-alive\s*(?:\z|,)/i
@header['connection']&.grep(token) {return true}
Expand Down
Loading