summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-10-16 15:36:28 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2009-10-16 15:36:28 +0200
commit592b78001c381f9cca6f20d8d1d47696bb98c0d1 (patch)
treea6c9a7d5f3015dbd3e168e90a37191aba3a532ac /methods
parent364af2ef2aba2911b12379ec8b6e55874e4b0a31 (diff)
port netrc support from maemon
Diffstat (limited to 'methods')
-rw-r--r--methods/http.cc7
-rw-r--r--methods/https.cc3
2 files changed, 8 insertions, 2 deletions
diff --git a/methods/http.cc b/methods/http.cc
index 1eba0f279..6bfe80baf 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -29,6 +29,7 @@
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
+#include <apt-pkg/netrc.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -42,6 +43,7 @@
#include <map>
#include <apti18n.h>
+
// Internet stuff
#include <netdb.h>
@@ -49,7 +51,6 @@
#include "connect.h"
#include "rfc2553emu.h"
#include "http.h"
-
/*}}}*/
using namespace std;
@@ -725,9 +726,11 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
Base64Encode(Proxy.User + ":" + Proxy.Password) + "\r\n";
if (Uri.User.empty() == false || Uri.Password.empty() == false)
+ {
+ maybe_add_auth (Uri, _config->FindFile("Dir::Etc::netrc"));
Req += string("Authorization: Basic ") +
Base64Encode(Uri.User + ":" + Uri.Password) + "\r\n";
-
+ }
Req += "User-Agent: Debian APT-HTTP/1.3 ("VERSION")\r\n\r\n";
if (Debug == true)
diff --git a/methods/https.cc b/methods/https.cc
index 37d93e308..a86c78029 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -14,6 +14,7 @@
#include <apt-pkg/acquire-method.h>
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
+#include <apt-pkg/netrc.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -126,6 +127,8 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
curl_easy_reset(curl);
SetupProxy();
+ maybe_add_auth (Uri, _config->FindFile("Dir::ETc::netrc"));
+
// callbacks
curl_easy_setopt(curl, CURLOPT_URL, Itm->Uri.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);