Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
Gem::Request.get_proxy_from_env
get_proxy_from_env(scheme = "http")
lib/rubygems/request.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/rubygems/request.rb, line 167
def self.get_proxy_from_env(scheme = "http")
downcase_scheme = scheme.downcase
upcase_scheme = scheme.upcase
env_proxy = ENV["#{downcase_scheme}_proxy"] || ENV["#{upcase_scheme}_PROXY"]
no_env_proxy = env_proxy.nil? || env_proxy.empty?
if no_env_proxy
return ["https", "http"].include?(downcase_scheme) ? :no_proxy : get_proxy_from_env("http")
end
require "uri"
uri = URI(Gem::UriFormatter.new(env_proxy).normalize)
if uri && uri.user.nil? && uri.password.nil?
user = ENV["#{downcase_scheme}_proxy_user"] || ENV["#{upcase_scheme}_PROXY_USER"]
password = ENV["#{downcase_scheme}_proxy_pass"] || ENV["#{upcase_scheme}_PROXY_PASS"]
uri.user = Gem::UriFormatter.new(user).escape
uri.password = Gem::UriFormatter.new(password).escape
end
uri
end
Returns a proxy URI for the given scheme if one is set in the environment variables.
See also
.get_cert_files
.new
.configure_connection_for_https
.verify_certificate
also in
4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0