summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
Diffstat (limited to 'methods')
-rw-r--r--methods/ftp.cc5
-rw-r--r--methods/http.cc7
-rw-r--r--methods/https.cc10
-rw-r--r--methods/https.h2
4 files changed, 18 insertions, 6 deletions
diff --git a/methods/ftp.cc b/methods/ftp.cc
index c91600ad5..3e1725823 100644
--- a/methods/ftp.cc
+++ b/methods/ftp.cc
@@ -19,6 +19,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>
@@ -982,7 +983,9 @@ bool FtpMethod::Fetch(FetchItem *Itm)
FetchResult Res;
Res.Filename = Itm->DestFile;
Res.IMSHit = false;
-
+
+ maybe_add_auth (Get, _config->FindFile("Dir::Etc::netrc"));
+
// Connect to the server
if (Server == 0 || Server->Comp(Get) == false)
{
diff --git a/methods/http.cc b/methods/http.cc
index 461a98406..3b210f6b6 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;
@@ -724,10 +725,12 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
Req += string("Proxy-Authorization: Basic ") +
Base64Encode(Proxy.User + ":" + Proxy.Password) + "\r\n";
+ maybe_add_auth (Uri, _config->FindFile("Dir::Etc::netrc"));
if (Uri.User.empty() == false || Uri.Password.empty() == false)
+ {
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 79e6fea3f..86d7f3a6b 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,8 +127,10 @@ 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_URL, static_cast<string>(Uri).c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, this);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
@@ -135,7 +138,6 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false);
curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
curl_easy_setopt(curl, CURLOPT_FILETIME, true);
- curl_easy_setopt(curl, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
// SSL parameters are set by default to the common (non mirror-specific) value
// if available (or a default one) and gets overload by mirror-specific ones.
@@ -213,8 +215,10 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
// set timeout
int timeout = _config->FindI("Acquire::http::Timeout",120);
- curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, timeout);
+ //set really low lowspeed timeout (see #497983)
+ curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, DL_MIN_SPEED);
+ curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, timeout);
// set redirect options and default to 10 redirects
bool AllowRedirect = _config->FindI("Acquire::https::AllowRedirect", true);
diff --git a/methods/https.h b/methods/https.h
index 2c33d95ee..3f0c416b6 100644
--- a/methods/https.h
+++ b/methods/https.h
@@ -24,6 +24,8 @@ class HttpsMethod;
class HttpsMethod : public pkgAcqMethod
{
+ // minimum speed in bytes/se that triggers download timeout handling
+ static const int DL_MIN_SPEED = 10;
virtual bool Fetch(FetchItem *);
static size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp);