summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
Diffstat (limited to 'methods')
-rw-r--r--methods/ftp.cc33
-rw-r--r--methods/http.cc31
-rw-r--r--methods/https.cc31
3 files changed, 56 insertions, 39 deletions
diff --git a/methods/ftp.cc b/methods/ftp.cc
index 554a24cf5..c91600ad5 100644
--- a/methods/ftp.cc
+++ b/methods/ftp.cc
@@ -112,23 +112,28 @@ bool FTPConn::Open(pkgAcqMethod *Owner)
Close();
// Determine the proxy setting
- if (getenv("ftp_proxy") == 0)
+ string SpecificProxy = _config->Find("Acquire::ftp::Proxy::" + ServerName.Host);
+ if (!SpecificProxy.empty())
{
- string DefProxy = _config->Find("Acquire::ftp::Proxy");
- string SpecificProxy = _config->Find("Acquire::ftp::Proxy::" + ServerName.Host);
- if (SpecificProxy.empty() == false)
- {
- if (SpecificProxy == "DIRECT")
- Proxy = "";
- else
- Proxy = SpecificProxy;
- }
- else
- Proxy = DefProxy;
+ if (SpecificProxy == "DIRECT")
+ Proxy = "";
+ else
+ Proxy = SpecificProxy;
}
else
- Proxy = getenv("ftp_proxy");
-
+ {
+ string DefProxy = _config->Find("Acquire::ftp::Proxy");
+ if (!DefProxy.empty())
+ {
+ Proxy = DefProxy;
+ }
+ else
+ {
+ char* result = getenv("ftp_proxy");
+ Proxy = result ? result : "";
+ }
+ }
+
// Parse no_proxy, a , separated list of domains
if (getenv("no_proxy") != 0)
{
diff --git a/methods/http.cc b/methods/http.cc
index 859dbd39c..7b61973d7 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -311,22 +311,27 @@ bool ServerState::Open()
Persistent = true;
// Determine the proxy setting
- if (getenv("http_proxy") == 0)
+ string SpecificProxy = _config->Find("Acquire::http::Proxy::" + ServerName.Host);
+ if (!SpecificProxy.empty())
{
- string DefProxy = _config->Find("Acquire::http::Proxy");
- string SpecificProxy = _config->Find("Acquire::http::Proxy::" + ServerName.Host);
- if (SpecificProxy.empty() == false)
- {
- if (SpecificProxy == "DIRECT")
- Proxy = "";
- else
- Proxy = SpecificProxy;
- }
- else
- Proxy = DefProxy;
+ if (SpecificProxy == "DIRECT")
+ Proxy = "";
+ else
+ Proxy = SpecificProxy;
}
else
- Proxy = getenv("http_proxy");
+ {
+ string DefProxy = _config->Find("Acquire::http::Proxy");
+ if (!DefProxy.empty())
+ {
+ Proxy = DefProxy;
+ }
+ else
+ {
+ char* result = getenv("http_proxy");
+ Proxy = result ? result : "";
+ }
+ }
// Parse no_proxy, a , separated list of domains
if (getenv("no_proxy") != 0)
diff --git a/methods/https.cc b/methods/https.cc
index 8bf44b52a..37d93e308 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -61,19 +61,26 @@ void HttpsMethod::SetupProxy()
URI ServerName = Queue->Uri;
// Determine the proxy setting
- if (getenv("http_proxy") == 0)
+ string SpecificProxy = _config->Find("Acquire::http::Proxy::" + ServerName.Host);
+ if (!SpecificProxy.empty())
{
- string DefProxy = _config->Find("Acquire::http::Proxy");
- string SpecificProxy = _config->Find("Acquire::http::Proxy::" + ServerName.Host);
- if (SpecificProxy.empty() == false)
- {
- if (SpecificProxy == "DIRECT")
- Proxy = "";
- else
- Proxy = SpecificProxy;
- }
- else
- Proxy = DefProxy;
+ if (SpecificProxy == "DIRECT")
+ Proxy = "";
+ else
+ Proxy = SpecificProxy;
+ }
+ else
+ {
+ string DefProxy = _config->Find("Acquire::http::Proxy");
+ if (!DefProxy.empty())
+ {
+ Proxy = DefProxy;
+ }
+ else
+ {
+ char* result = getenv("http_proxy");
+ Proxy = result ? result : "";
+ }
}
// Parse no_proxy, a , separated list of domains