summaryrefslogtreecommitdiff
path: root/methods/https.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2012-01-30 16:26:10 +0100
committerDavid Kalnischkies <kalnischkies@gmail.com>2012-01-30 16:26:10 +0100
commit6f4501f96f9ea256ff580129ba3835e0d56c398a (patch)
tree115e5c1eeeb8a8843869c7345a8555e8e0c6df26 /methods/https.cc
parent017f9fd68258b15ac4df5ae73b19ba6653711022 (diff)
* methods/http{s,}.cc:
- if a file without an extension is requested send an 'Accept: text/*' header to avoid that the server chooses unsupported compressed files in a content-negotation attempt (Closes: #657560)
Diffstat (limited to 'methods/https.cc')
-rw-r--r--methods/https.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/methods/https.cc b/methods/https.cc
index 6de18b8e0..4f2d581d2 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -242,6 +242,19 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
// error handling
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errorstr);
+ // If we ask for uncompressed files servers might respond with content-
+ // negotation which lets us end up with compressed files we do not support,
+ // see 657029, 657560 and co, so if we have no extension on the request
+ // ask for text only. As a sidenote: If there is nothing to negotate servers
+ // seem to be nice and ignore it.
+ if (_config->FindB("Acquire::https::SendAccept", _config->FindB("Acquire::http::SendAccept", true)) == true)
+ {
+ size_t const filepos = Itm->Uri.find_last_of('/');
+ string const file = Itm->Uri.substr(filepos + 1);
+ if (flExtension(file) == file)
+ headers = curl_slist_append(headers, "Accept: text/*");
+ }
+
// if we have the file send an if-range query with a range header
if (stat(Itm->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0)
{