]> git.saurik.com Git - apt.git/blobdiff - methods/https.cc
properly handle if-modfied-since with libcurl/https
[apt.git] / methods / https.cc
index c1a49ba6093b621743dd2726f329d79f1f3eeff9..d85415b2f0b28d6c250f1bc2b53a11d4e2e9c064 100644 (file)
@@ -285,6 +285,11 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
    long curl_servdate;
    curl_easy_getinfo(curl, CURLINFO_FILETIME, &curl_servdate);
 
+   // If the server returns 200 OK but the If-Modified-Since condition is not
+   // met, CURLINFO_CONDITION_UNMET will be set to 1
+   long curl_condition_unmet = 0;
+   curl_easy_getinfo(curl, CURLINFO_CONDITION_UNMET, &curl_condition_unmet);
+
    File->Close();
 
    // cleanup
@@ -312,7 +317,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
       Res.Filename = File->Name();
       Res.LastModified = Buf.st_mtime;
       Res.IMSHit = false;
-      if (curl_responsecode == 304)
+      if (curl_responsecode == 304 || curl_condition_unmet)
       {
         unlink(File->Name().c_str());
         Res.IMSHit = true;