mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
Check for empty string when configuring proxies
On some Linux system like debian, the `HTTP_PROXY` are set to an empty string and was causing the plugin manager to raise an exception. We now strip the string and check if it is empty before trying to configure the proxies. Fixes: #7045 Fixes #7065
This commit is contained in:
parent
943147a2f8
commit
17c2f37b25
2 changed files with 21 additions and 2 deletions
|
@ -56,14 +56,16 @@ end
|
|||
|
||||
def configure_proxy
|
||||
proxies = []
|
||||
if proxy = (ENV["http_proxy"] || ENV["HTTP_PROXY"])
|
||||
proxy = (ENV["http_proxy"] || ENV["HTTP_PROXY"])
|
||||
if !proxy.nil? && !proxy.strip.empty?
|
||||
proxy_settings = extract_proxy_values_from_uri(proxy)
|
||||
proxy_settings[:protocol] = "http"
|
||||
apply_env_proxy_settings(proxy_settings)
|
||||
proxies << proxy_settings
|
||||
end
|
||||
|
||||
if proxy = (ENV["https_proxy"] || ENV["HTTPS_PROXY"])
|
||||
proxy = (ENV["https_proxy"] || ENV["HTTPS_PROXY"])
|
||||
if !proxy.nil? && !proxy.strip.empty?
|
||||
proxy_settings = extract_proxy_values_from_uri(proxy)
|
||||
proxy_settings[:protocol] = "https"
|
||||
apply_env_proxy_settings(proxy_settings)
|
||||
|
|
|
@ -112,4 +112,21 @@ describe "Proxy support" do
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
context "when proxies are set with an empty string" do
|
||||
let(:environments) {
|
||||
{
|
||||
"http_proxy" => "",
|
||||
"https_proxy" => ""
|
||||
}
|
||||
}
|
||||
|
||||
before do
|
||||
environments.each { |key, value| ENV[key] = value }
|
||||
end
|
||||
|
||||
it "doesn't raise an exception" do
|
||||
expect { configure_proxy }.not_to raise_exception
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue