+
+ case MessageType::REDIRECT:
+ {
+ if (Itm == nullptr)
+ {
+ _error->Error("Method gave invalid 103 Redirect message");
+ break;
+ }
+
+ std::string const NewURI = LookupTag(Message,"New-URI",URI.c_str());
+ Itm->URI = NewURI;
+
+ ItemDone();
+
+ // Change the status so that it can be dequeued
+ for (auto const &O: Itm->Owners)
+ O->Status = pkgAcquire::Item::StatIdle;
+ // Mark the item as done (taking care of all queues)
+ // and then put it in the main queue again
+ std::vector<Item*> const ItmOwners = Itm->Owners;
+ OwnerQ->ItemDone(Itm);
+ Itm = nullptr;
+ for (auto const &Owner: ItmOwners)
+ {
+ pkgAcquire::ItemDesc &desc = Owner->GetItemDesc();
+ if (Log != nullptr)
+ Log->Done(desc);
+
+ // if we change site, treat it as a mirror change
+ if (URI::SiteOnly(NewURI) != URI::SiteOnly(desc.URI))
+ {
+ auto const firstSpace = desc.Description.find(" ");
+ if (firstSpace != std::string::npos)
+ {
+ std::string const OldSite = desc.Description.substr(0, firstSpace);
+ if (likely(APT::String::Startswith(desc.URI, OldSite)))
+ {
+ std::string const OldExtra = desc.URI.substr(OldSite.length() + 1);
+ if (likely(APT::String::Endswith(NewURI, OldExtra)))
+ {
+ std::string const NewSite = NewURI.substr(0, NewURI.length() - OldExtra.length());
+ Owner->UsedMirror = URI::ArchiveOnly(NewSite);
+ desc.Description.replace(0, firstSpace, Owner->UsedMirror);
+ }
+ }
+ }
+ }
+ desc.URI = NewURI;
+ if (isDoomedItem(Owner) == false)
+ OwnerQ->Owner->Enqueue(desc);
+ }
+ break;
+ }
+
+ case MessageType::WARNING:
+ _error->Warning("%s: %s", Itm->Owner->DescURI().c_str(), LookupTag(Message,"Message").c_str());
+ break;
+
+ case MessageType::URI_START: