+
+ // 101 Log
+ case 101:
+ if (Debug == true)
+ clog << " <- (log) " << LookupTag(Message,"Message") << endl;
+ break;
+
+ // 102 Status
+ case 102:
+ 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:
+ {
+ if (Itm == 0)
+ {
+ _error->Error("Method gave invalid 200 URI Start message");
+ break;
+ }
+
+ CurrentItem = Itm;
+ CurrentSize = 0;
+ TotalSize = atoi(LookupTag(Message,"Size","0").c_str());
+ ResumePoint = atoi(LookupTag(Message,"Resume-Point","0").c_str());
+ Itm->Owner->Start(Message,atoi(LookupTag(Message,"Size","0").c_str()));
+
+ // Display update before completion
+ if (Log != 0 && Log->MorePulses == true)
+ Log->Pulse(Itm->Owner->GetOwner());
+
+ if (Log != 0)
+ Log->Fetch(*Itm);
+
+ break;
+ }
+
+ // 201 URI Done
+ case 201:
+ {
+ if (Itm == 0)
+ {
+ _error->Error("Method gave invalid 201 URI Done message");
+ break;
+ }
+
+ pkgAcquire::Item *Owner = Itm->Owner;
+ pkgAcquire::ItemDesc Desc = *Itm;
+
+ // Display update before completion
+ if (Log != 0 && Log->MorePulses == true)
+ Log->Pulse(Owner->GetOwner());
+
+ OwnerQ->ItemDone(Itm);
+ if (TotalSize != 0 &&
+ (unsigned)atoi(LookupTag(Message,"Size","0").c_str()) != TotalSize)
+ _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()),
+ RecivedHash.c_str(), Config);
+ ItemDone();
+
+ // Log that we are done
+ if (Log != 0)
+ {
+ if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true ||
+ StringToBool(LookupTag(Message,"Alt-IMS-Hit"),false) == true)
+ {
+ /* Hide 'hits' for local only sources - we also manage to
+ hide gets */
+ if (Config->LocalOnly == false)
+ Log->IMSHit(Desc);
+ }
+ else
+ Log->Done(Desc);
+ }
+ break;
+ }
+
+ // 400 URI Failure
+ case 400:
+ {
+ if (Itm == 0)
+ {
+ _error->Error("Method gave invalid 400 URI Failure message");
+ break;
+ }
+
+ // Display update before completion
+ if (Log != 0 && Log->MorePulses == true)
+ Log->Pulse(Itm->Owner->GetOwner());
+
+ pkgAcquire::Item *Owner = Itm->Owner;
+ pkgAcquire::ItemDesc Desc = *Itm;
+ OwnerQ->ItemDone(Itm);
+
+ // 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;
+
+ Owner->Failed(Message,Config);
+ ItemDone();
+
+ if (Log != 0)
+ Log->Fail(Desc);
+
+ break;
+ }
+
+ // 401 General Failure
+ case 401:
+ _error->Error("Method %s General failure: %s",Access.c_str(),LookupTag(Message,"Message").c_str());
+ break;
+
+ // 403 Media Change
+ case 403:
+ MediaChange(Message);
+ break;