summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
Diffstat (limited to 'methods')
-rw-r--r--methods/connect.cc11
-rw-r--r--methods/http.cc6
-rw-r--r--methods/https.cc4
-rw-r--r--methods/https.h5
4 files changed, 23 insertions, 3 deletions
diff --git a/methods/connect.cc b/methods/connect.cc
index 9a092a43c..fc7a72ee9 100644
--- a/methods/connect.cc
+++ b/methods/connect.cc
@@ -17,6 +17,7 @@
#include <apt-pkg/fileutl.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/acquire-method.h>
+#include <apt-pkg/configuration.h>
#include <stdio.h>
#include <errno.h>
@@ -167,6 +168,13 @@ bool Connect(std::string Host,int Port,const char *Service,int DefPort,int &Fd,
Hints.ai_flags = AI_ADDRCONFIG;
Hints.ai_protocol = 0;
+ if(_config->FindB("Acquire::ForceIPv4", false) == true)
+ Hints.ai_family = AF_INET;
+ else if(_config->FindB("Acquire::ForceIPv6", false) == true)
+ Hints.ai_family = AF_INET6;
+ else
+ Hints.ai_family = AF_UNSPEC;
+
// if we couldn't resolve the host before, we don't try now
if(bad_addr.find(Host) != bad_addr.end())
return _error->Error(_("Could not resolve '%s'"),Host.c_str());
@@ -197,6 +205,9 @@ bool Connect(std::string Host,int Port,const char *Service,int DefPort,int &Fd,
return _error->Error(_("Temporary failure resolving '%s'"),
Host.c_str());
}
+ if (Res == EAI_SYSTEM)
+ return _error->Errno("getaddrinfo", _("System error resolving '%s:%s'"),
+ Host.c_str(),ServStr);
return _error->Error(_("Something wicked happened resolving '%s:%s' (%i - %s)"),
Host.c_str(),ServStr,Res,gai_strerror(Res));
}
diff --git a/methods/http.cc b/methods/http.cc
index acf25a42a..fddf8a78e 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -685,8 +685,12 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
pass it on, HTTP/1.1 says the connection should default to keep alive
and we expect the proxy to do this */
if (Proxy.empty() == true || Proxy.Host.empty())
+ {
+ // see LP bugs #1003633 and #1086997. The "+" is encoded as a workaround
+ // for a amazon S3 bug
sprintf(Buf,"GET %s HTTP/1.1\r\nHost: %s\r\nConnection: keep-alive\r\n",
- QuoteString(Uri.Path,"~").c_str(),ProperHost.c_str());
+ QuoteString(Uri.Path,"+~ ").c_str(),ProperHost.c_str());
+ }
else
{
/* Generate a cache control header if necessary. We place a max
diff --git a/methods/https.cc b/methods/https.cc
index c1a49ba60..11d4ba8aa 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -124,7 +124,6 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, this);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, false);
- curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);
curl_easy_setopt(curl, CURLOPT_FILETIME, true);
// SSL parameters are set by default to the common (non mirror-specific) value
@@ -240,6 +239,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
// error handling
+ curl_errorstr[0] = '\0';
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errorstr);
// If we ask for uncompressed files servers might respond with content-
@@ -288,7 +288,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
File->Close();
// cleanup
- if(success != 0)
+ if(success != 0 || (curl_responsecode != 200 && curl_responsecode != 304))
{
_error->Error("%s", curl_errorstr);
// unlink, no need keep 401/404 page content in partial/
diff --git a/methods/https.h b/methods/https.h
index b1961a870..293e288e0 100644
--- a/methods/https.h
+++ b/methods/https.h
@@ -41,6 +41,11 @@ class HttpsMethod : public pkgAcqMethod
File = 0;
curl = curl_easy_init();
};
+
+ ~HttpsMethod()
+ {
+ curl_easy_cleanup(curl);
+ };
};
#include <apt-pkg/strutl.h>