X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/a530607f8ac4936402831d854f171fc8dc89ef4f..b74d2d3af3238210bfafe57562d3670327918cd9:/methods/https.cc

diff --git a/methods/https.cc b/methods/https.cc
index 98dfeefa1..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
@@ -208,6 +215,11 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
    curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
    curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, timeout);
 
+   // set redirect options and default to 10 redirects
+   bool AllowRedirect = _config->FindI("Acquire::https::AllowRedirect", true);
+   curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, AllowRedirect);
+   curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 10);
+
    // debug
    if(_config->FindB("Debug::Acquire::https", false))
       curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
@@ -248,7 +260,6 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
    // cleanup
    if(success != 0) 
    {
-      unlink(File->Name().c_str());
       _error->Error("%s", curl_errorstr);
       Fail();
       return true;