From bfd22aac78564637b95b5b0d65078ec08e219dd9 Mon Sep 17 00:00:00 2001 From: Richard Grainger Date: Wed, 8 Dec 2021 10:11:50 +0000 Subject: [PATCH] Explicitly set proxy in uri_options --- lib/puppet_forge_server/http/http_client.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/puppet_forge_server/http/http_client.rb b/lib/puppet_forge_server/http/http_client.rb index fbd3949..5093d34 100644 --- a/lib/puppet_forge_server/http/http_client.rb +++ b/lib/puppet_forge_server/http/http_client.rb @@ -35,9 +35,11 @@ def initialize(cache = nil) 'User-Agent' => "Puppet-Forge-Server/#{PuppetForgeServer::VERSION}", :allow_redirections => :safe, } - # OpenURI does not work with http_proxy=http://username:password@proxyserver:port/ - # so split the proxy_url and feed it basic authentication. + # Explicitly set proxy in uri_options if ENV.has_key?('http_proxy') + @uri_options[:proxy] = URI.parse(ENV['http_proxy']) + # OpenURI does not work with http_proxy=http://username:password@proxyserver:port/ + # so split the proxy_url and feed it basic authentication. proxy = URI.parse(ENV['http_proxy']) if proxy.userinfo != nil @uri_options[:proxy_http_basic_authentication] = [