summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-02-18 15:17:50 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2010-02-18 15:17:50 +0100
commitb9dacd11a4707092f070d49b1cb1acff642eebf0 (patch)
tree8876729757ce5b5d639c13018d8fee79d308929c /methods
parentb026dbb970c71213e12caaeb47bf7a27b91ea0a0 (diff)
parentb8c42fc0632dbbe0edb0854cd941a8fc5340a94a (diff)
* [BREAK] merged lp:~mvo/apt/history
- this writes a /var/log/apt/history tagfile that contains details from the transaction (complements term.log) * methods/http.cc: - add cache-control headers even if no cache is given to allow adding options for intercepting proxies - add Acquire::http::ProxyAutoDetect configuration that can be used to call a external helper to figure out the proxy configuration and return it to apt via stdout (this is a step towards WPAD and zeroconf/avahi support) * abicheck/ - add new abitest tester using the ABI Compliance Checker from http://ispras.linuxfoundation.org/index.php/ABI_compliance_checker * Change the package index Info methods to allow apt-cache policy to be useful when using several different archives on the same host. (Closes: #329814, LP: #22354)
Diffstat (limited to 'methods')
-rw-r--r--methods/cdrom.cc2
-rw-r--r--methods/http.cc79
-rw-r--r--methods/http.h2
3 files changed, 67 insertions, 16 deletions
diff --git a/methods/cdrom.cc b/methods/cdrom.cc
index 6d694e7c9..bf4281e40 100644
--- a/methods/cdrom.cc
+++ b/methods/cdrom.cc
@@ -219,7 +219,7 @@ bool CDROMMethod::Fetch(FetchItem *Itm)
return true;
}
- bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect", false);
+ bool AutoDetect = _config->FindB("Acquire::cdrom::AutoDetect", true);
CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/");
if (Debug)
clog << "Looking for CDROM at " << CDROM << endl;
diff --git a/methods/http.cc b/methods/http.cc
index 2dae87a02..b05444691 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -682,23 +682,25 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
and a no-store directive for archives. */
sprintf(Buf,"GET %s HTTP/1.1\r\nHost: %s\r\n",
Itm->Uri.c_str(),ProperHost.c_str());
- // only generate a cache control header if we actually want to
- // use a cache
- if (_config->FindB("Acquire::http::No-Cache",false) == false)
+ }
+ // generate a cache control header (if needed)
+ if (_config->FindB("Acquire::http::No-Cache",false) == true)
+ {
+ strcat(Buf,"Cache-Control: no-cache\r\nPragma: no-cache\r\n");
+ }
+ else
+ {
+ if (Itm->IndexFile == true)
{
- if (Itm->IndexFile == true)
- sprintf(Buf+strlen(Buf),"Cache-Control: max-age=%u\r\n",
- _config->FindI("Acquire::http::Max-Age",0));
- else
- {
- if (_config->FindB("Acquire::http::No-Store",false) == true)
- strcat(Buf,"Cache-Control: no-store\r\n");
- }
+ sprintf(Buf+strlen(Buf),"Cache-Control: max-age=%u\r\n",
+ _config->FindI("Acquire::http::Max-Age",0));
+ }
+ else
+ {
+ if (_config->FindB("Acquire::http::No-Store",false) == true)
+ strcat(Buf,"Cache-Control: no-store\r\n");
}
}
- // generate a no-cache header if needed
- if (_config->FindB("Acquire::http::No-Cache",false) == true)
- strcat(Buf,"Cache-Control: no-cache\r\nPragma: no-cache\r\n");
string Req = Buf;
@@ -1071,7 +1073,11 @@ bool HttpMethod::Configuration(string Message)
PipelineDepth = _config->FindI("Acquire::http::Pipeline-Depth",
PipelineDepth);
Debug = _config->FindB("Debug::Acquire::http",false);
-
+ AutoDetectProxyCmd = _config->Find("Acquire::http::ProxyAutoDetect");
+
+ // Get the proxy to use
+ AutoDetectProxy();
+
return true;
}
/*}}}*/
@@ -1321,6 +1327,49 @@ int HttpMethod::Loop()
return 0;
}
/*}}}*/
+// HttpMethod::AutoDetectProxy - auto detect proxy /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool HttpMethod::AutoDetectProxy()
+{
+ if (AutoDetectProxyCmd.empty())
+ return true;
+
+ if (Debug)
+ clog << "Using auto proxy detect command: " << AutoDetectProxyCmd << endl;
+
+ int Pipes[2] = {-1,-1};
+ if (pipe(Pipes) != 0)
+ return _error->Errno("pipe", "Failed to create Pipe");
+
+ pid_t Process = ExecFork();
+ if (Process == 0)
+ {
+ dup2(Pipes[1],STDOUT_FILENO);
+ SetCloseExec(STDOUT_FILENO,false);
+
+ const char *Args[2];
+ Args[0] = AutoDetectProxyCmd.c_str();
+ Args[1] = 0;
+ execv(Args[0],(char **)Args);
+ cerr << "Failed to exec method " << Args[0] << endl;
+ _exit(100);
+ }
+ char buf[512];
+ int InFd = Pipes[0];
+ if (read(InFd, buf, sizeof(buf)) < 0)
+ return _error->Errno("read", "Failed to read");
+ ExecWait(Process, "ProxyAutoDetect");
+
+ if (Debug)
+ clog << "auto detect command returned: '" << buf << "'" << endl;
+
+ if (strstr(buf, "http://") == buf)
+ _config->Set("Acquire::http::proxy", _strstrip(buf));
+
+ return true;
+}
+ /*}}}*/
int main()
{
diff --git a/methods/http.h b/methods/http.h
index 13f02ec77..ceee36cbe 100644
--- a/methods/http.h
+++ b/methods/http.h
@@ -134,6 +134,7 @@ class HttpMethod : public pkgAcqMethod
bool Flush(ServerState *Srv);
bool ServerDie(ServerState *Srv);
int DealWithHeaders(FetchResult &Res,ServerState *Srv);
+ bool AutoDetectProxy();
virtual bool Fetch(FetchItem *);
virtual bool Configuration(string Message);
@@ -145,6 +146,7 @@ class HttpMethod : public pkgAcqMethod
static void SigTerm(int);
string NextURI;
+ string AutoDetectProxyCmd;
public:
friend class ServerState;