Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change how ruby proxy is invoked. #280

Merged
merged 1 commit into from
Aug 2, 2017
Merged
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
13 changes: 9 additions & 4 deletions lib/puppet_x/bodeco/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ def initialize(_url, options)
@password = options[:password]
@cookie = options[:cookie]
@insecure = options[:insecure]
proxy_server = options[:proxy_server]
proxy_type = options[:proxy_type]

ENV["#{proxy_type}_proxy"] = proxy_server
if options[:proxy_server]
uri = URI(options[:proxy_server])
unless uri.scheme
uri = URI("#{options[:proxy_type]}://#{options[:proxy_server]}")
Copy link
Member

@alexjfisher alexjfisher May 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should never be hit?

I still think we've got confusion about what proxy_type is supposed to do. Is it the scheme of the URL needing proxying, or the scheme of the proxy server URL? At the moment, the parameters behave differently depending on the provider.
According to the README and original proxy PR, proxy_server is supposed to be of the form http://my_proxy.example.com:3128 ? I think it's confusing to try and support multiple forms considering the already differing behaviour between providers.

end
@proxy_addr = uri.hostname
@proxy_port = uri.port
end

ENV['SSL_CERT_FILE'] = File.expand_path(File.join(__FILE__, '..', 'cacert.pem')) if Facter.value(:osfamily) == 'windows' && !ENV.key?('SSL_CERT_FILE')
end
Expand All @@ -48,7 +53,7 @@ def follow_redirect(uri, option = { limit: FOLLOW_LIMIT }, &block)
else
{ use_ssl: false }
end
Net::HTTP.start(uri.host, uri.port, http_opts) do |http|
Net::HTTP.start(uri.host, uri.port, @proxy_addr, @proxy_port, http_opts) do |http|
http.request(generate_request(uri)) do |response|
case response
when Net::HTTPSuccess
Expand Down