Bläddra i källkod

merged from lp:~mvo/apt/mvo

Michael Vogt 16 år sedan
förälder
incheckning
424d785b67
2 ändrade filer med 19 tillägg och 14 borttagningar
  1. 3 0
      debian/changelog
  2. 16 14
      methods/http.cc

+ 3 - 0
debian/changelog

@@ -3,6 +3,9 @@ apt (0.7.25ubuntu4) lucid; urgency=low
   * cmdline/apt-cdrom.cc:
     - make Acquire::cdrom::AutoDetect default, this can be
       turned off with "--no-auto-detect"
+  * methods/http.cc:
+    - add cache-control headers even if no cache is given to allow
+      adding options for intercepting proxies
 
  -- Michael Vogt <michael.vogt@ubuntu.com>  Tue, 02 Feb 2010 16:58:59 -0800
 

+ 16 - 14
methods/http.cc

@@ -682,23 +682,25 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
        	 and a no-store directive for archives. */
       sprintf(Buf,"GET %s HTTP/1.1\r\nHost: %s\r\n",
 	      Itm->Uri.c_str(),ProperHost.c_str());
-      // only generate a cache control header if we actually want to 
-      // use a cache
-      if (_config->FindB("Acquire::http::No-Cache",false) == false)
+   }
+   // generate a cache control header (if needed)
+   if (_config->FindB("Acquire::http::No-Cache",false) == true) 
+   {
+      strcat(Buf,"Cache-Control: no-cache\r\nPragma: no-cache\r\n");
+   }
+   else
+   {
+      if (Itm->IndexFile == true) 
       {
-	 if (Itm->IndexFile == true)
-	    sprintf(Buf+strlen(Buf),"Cache-Control: max-age=%u\r\n",
-		    _config->FindI("Acquire::http::Max-Age",0));
-	 else
-	 {
-	    if (_config->FindB("Acquire::http::No-Store",false) == true)
-	       strcat(Buf,"Cache-Control: no-store\r\n");
-	 }	 
+	 sprintf(Buf+strlen(Buf),"Cache-Control: max-age=%u\r\n",
+		 _config->FindI("Acquire::http::Max-Age",0));
+      }
+      else
+      {
+	 if (_config->FindB("Acquire::http::No-Store",false) == true)
+	    strcat(Buf,"Cache-Control: no-store\r\n");
       }
    }
-   // generate a no-cache header if needed
-   if (_config->FindB("Acquire::http::No-Cache",false) == true)
-      strcat(Buf,"Cache-Control: no-cache\r\nPragma: no-cache\r\n");
 
    
    string Req = Buf;