Skip to content

Commit

Permalink
Merge pull request ManageIQ#18105 from jrafanie/rest_client_monkey_pa…
Browse files Browse the repository at this point in the history
…tch4percent_encoded_proxy_user_password

RestClient: Support percent encoded proxy user/pass
  • Loading branch information
bdunne authored Oct 19, 2018
2 parents 9b265d4 + d2b0e32 commit 5a784c3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/patches/rest_client_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require 'restclient/version'
if RestClient::VERSION >= "2.0.0" && RestClient::VERSION <= "2.1.0"
require 'restclient/request'
RestClient::Request.module_eval do
def net_http_object(hostname, port)
p_uri = proxy_uri

if p_uri.nil?
# no proxy set
Net::HTTP.new(hostname, port)
elsif !p_uri
# proxy explicitly set to none
Net::HTTP.new(hostname, port, nil, nil, nil, nil)
else
pass = p_uri.password ? CGI.unescape(p_uri.password) : nil
user = p_uri.user ? CGI.unescape(p_uri.user) : nil
Net::HTTP.new(hostname, port,
p_uri.hostname, p_uri.port, user, pass)

end
end
end
else
# The above patched method was last modified in 2015 and should be stable in
# patch releases. With 2.1 or newer, we need verify PR below was included or
# if this monkey patch needs to change
# https://github.com/rest-client/rest-client/pull/665
warn "This RestClient patch for proxy's with percent encoded user/password is for versions ~> 2.0.0. Please check if this patch is required for version #{RestClient::VERSION}, see: #{__FILE__}"
end
1 change: 1 addition & 0 deletions lib/vmdb_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

# Include monkey-patches
$:.push("#{File.dirname(__FILE__)}/patches")
require 'rest_client_patch'
require 'ruport_patch'

APPLIANCE_DATA_VOL = File.directory?("/var/www/miq/vmdb") ? "/var/lib/data" : Rails.root.join("tmp")
Expand Down

0 comments on commit 5a784c3

Please sign in to comment.