forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ManageIQ#18105 from jrafanie/rest_client_monkey_pa…
…tch4percent_encoded_proxy_user_password RestClient: Support percent encoded proxy user/pass
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters