* fix the cache-control header generation
authorMichael Vogt <michael.vogt@ubuntu.com>
Thu, 19 May 2005 08:26:28 +0000 (08:26 +0000)
committerMichael Vogt <michael.vogt@ubuntu.com>
Thu, 19 May 2005 08:26:28 +0000 (08:26 +0000)
* methods/http.cc:
  a cache cache header can now be generated even if no proxy is
  specified to support "no-cache" for transparent proxies

debian/changelog
methods/http.cc

index 42470ea..13bce19 100644 (file)
@@ -4,6 +4,8 @@ apt (0.6.37) experimental; urgency=low
     the virtual pkg (thanks to otavio)
   * make pinning on the "component" work again (using the section of the 
     archive, we don't use per-section Release files anymore with apt-0.6)
+  * make it possible to write a cache-control: no-cache header even if
+    no proxy is set to support transparent proxies (closes ubuntu: #10773)
 
  --
 
index 81a64d7..ba86aa6 100644 (file)
@@ -635,9 +635,9 @@ 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());
-      if (_config->FindB("Acquire::http::No-Cache",false) == true)
-        strcat(Buf,"Cache-Control: no-cache\r\nPragma: no-cache\r\n");
-      else
+      // only generate a cache control header if we actually want to 
+      // use a cache
+      if (_config->FindB("Acquire::http::No-Cache",false) == false)
       {
         if (Itm->IndexFile == true)
            sprintf(Buf+strlen(Buf),"Cache-Control: max-age=%u\r\n",
@@ -649,6 +649,10 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
         }       
       }
    }
+   // 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;