summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-method.cc32
-rw-r--r--apt-pkg/acquire-method.h2
-rw-r--r--apt-pkg/acquire-worker.cc14
-rw-r--r--apt-pkg/makefile2
4 files changed, 49 insertions, 1 deletions
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index bc29417f7..acf1156dc 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -447,6 +447,38 @@ void pkgAcqMethod::Status(const char *Format,...)
}
/*}}}*/
+// AcqMethod::Redirect - Send a redirect message /*{{{*/
+// ---------------------------------------------------------------------
+/* This method sends the redirect message and also manipulates the queue
+ to keep the pipeline synchronized. */
+void pkgAcqMethod::Redirect(const string &NewURI)
+{
+ string CurrentURI = "<UNKNOWN>";
+ if (Queue != 0)
+ CurrentURI = Queue->Uri;
+
+ char S[1024];
+ snprintf(S, sizeof(S)-50, "103 Redirect\nURI: %s\nNew-URI: %s\n\n",
+ CurrentURI.c_str(), NewURI.c_str());
+
+ if (write(STDOUT_FILENO,S,strlen(S)) != (ssize_t)strlen(S))
+ exit(100);
+
+ // Change the URI for the request.
+ Queue->Uri = NewURI;
+
+ /* To keep the pipeline synchronized, move the current request to
+ the end of the queue, past the end of the current pipeline. */
+ FetchItem *I;
+ for (I = Queue; I->Next != 0; I = I->Next) ;
+ I->Next = Queue;
+ Queue = Queue->Next;
+ I->Next->Next = 0;
+ if (QueueBack == 0)
+ QueueBack = I->Next;
+}
+ /*}}}*/
+
// AcqMethod::FetchResult::FetchResult - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h
index e02eab018..fab77e664 100644
--- a/apt-pkg/acquire-method.h
+++ b/apt-pkg/acquire-method.h
@@ -84,6 +84,8 @@ class pkgAcqMethod
void Log(const char *Format,...);
void Status(const char *Format,...);
+ void Redirect(const string &NewURI);
+
int Run(bool Single = false);
inline void SetFailExtraMsg(string Msg) {FailExtra = Msg;};
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index 1a754dae9..78c68737c 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -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:
{
diff --git a/apt-pkg/makefile b/apt-pkg/makefile
index 1b78c94f6..087f17740 100644
--- a/apt-pkg/makefile
+++ b/apt-pkg/makefile
@@ -13,7 +13,7 @@ include ../buildlib/defaults.mak
# methods/makefile - FIXME
LIBRARY=apt-pkg
LIBEXT=$(GLIBC_VER)$(LIBSTDCPP_VER)
-MAJOR=4.6
+MAJOR=4.7
MINOR=0
SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil
APT_DOMAIN:=libapt-pkg$(MAJOR)