]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/acquire-worker.cc
* [ABI break] merge support for http redirects, thanks to
[apt.git] / apt-pkg / acquire-worker.cc
index 25d40ef542f82a7f8af80c75e6284b6b2c1cf7ff..78c68737c32f4d3aef1a37de6314e6b4cfd4d3e8 100644 (file)
@@ -220,6 +220,20 @@ bool pkgAcquire::Worker::RunMessages()
         Status = LookupTag(Message,"Message");
         break;
            
+         // 103 Redirect
+         case 103:
+         {
+            if (Itm == 0)
+            {
+               _error->Error("Method gave invalid 103 Redirect message");
+               break;
+            }
+            string NewURI = LookupTag(Message,"New-URI",URI.c_str());
+            Itm->URI = NewURI;
+            break;
+         }
+   
         // 200 URI Start
         case 200:
         {
@@ -267,8 +281,25 @@ bool pkgAcquire::Worker::RunMessages()
               _error->Warning("Bizarre Error - File size is not what the server reported %s %lu",
                               LookupTag(Message,"Size","0").c_str(),TotalSize);
 
+           // see if there is a hash to verify
+           string RecivedHash;
+           HashString expectedHash(Owner->HashSum());
+           if(!expectedHash.empty()) 
+           {
+              string hashTag = expectedHash.HashType()+"-Hash";
+              string hashSum = LookupTag(Message, hashTag.c_str());
+              if(!hashSum.empty())
+                 RecivedHash = expectedHash.HashType() + ":" + hashSum;
+              if(_config->FindB("Debug::pkgAcquire::Auth", false) == true)
+              {
+                 clog << "201 URI Done: " << Owner->DescURI() << endl
+                      << "RecivedHash: " << RecivedHash << endl
+                      << "ExpectedHash: " << expectedHash.toStr() 
+                      << endl << endl;
+              }
+           }
            Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
-                       LookupTag(Message,"MD5-Hash"),Config);
+                       RecivedHash.c_str(), Config);
            ItemDone();
            
            // Log that we are done
@@ -308,6 +339,7 @@ bool pkgAcquire::Worker::RunMessages()
            // set some status
            if(LookupTag(Message,"FailReason") == "Timeout" || 
               LookupTag(Message,"FailReason") == "TmpResolveFailure" ||
+              LookupTag(Message,"FailReason") == "ResolveFailure" ||
               LookupTag(Message,"FailReason") == "ConnectionRefused") 
               Owner->Status = pkgAcquire::Item::StatTransientNetworkError;