- merge repomd branch
[apt.git] / apt-pkg / acquire-worker.cc
index 93ddde1..a1dfe76 100644 (file)
@@ -241,6 +241,20 @@ bool pkgAcquire::Worker::RunMessages()
         case 179:
         Config->PreferredURI = LookupTag(Message, "PreferredURI");
         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:
@@ -289,8 +303,11 @@ 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);
 
+           // LORG:2006-03-09
+           // Look up the checksum type from owner
            Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
-                       LookupTag(Message,"MD5-Hash"),Config);
+                       LookupTag(Message,Owner->ChecksumType().c_str()),Config);
+           
            ItemDone();
            
            // Log that we are done
@@ -344,6 +361,11 @@ bool pkgAcquire::Worker::RunMessages()
         case 403:
         MediaChange(Message); 
         break;
+
+        // 404 Authenticate
+        case 404:
+        Authenticate(Message);
+        break;
       }      
    }
    return true;
@@ -412,6 +434,34 @@ bool pkgAcquire::Worker::MediaChange(string Message)
    return true;
 }
                                                                        /*}}}*/
+// Worker::Authenticate - Request authentication                               /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool pkgAcquire::Worker::Authenticate(string Message)
+{
+   string User, Pass;
+   if (Log == 0 || Log->Authenticate(LookupTag(Message,"Description"),
+                                    User,Pass) == false)
+   {
+      char S[300];
+      snprintf(S,sizeof(S),"604 Authenticated\nFailed: true\n\n");
+      if (Debug == true)
+        clog << " -> " << Access << ':' << QuoteString(S,"\n") << endl;
+      OutQueue += S;
+      OutReady = true;
+      return true;
+   }
+
+   char S[300];
+   snprintf(S,sizeof(S),"604 Authenticated\nUser: %s\nPassword: %s\n\n",
+           User.c_str(), Pass.c_str());
+   if (Debug == true)
+      clog << " -> " << Access << ':' << QuoteString(S,"\n") << endl;
+   OutQueue += S;
+   OutReady = true;
+   return true;
+}
+                                                                       /*}}}*/
 // Worker::SendConfiguration - Send the config to the method           /*{{{*/
 // ---------------------------------------------------------------------
 /* */