]> git.saurik.com Git - apt.git/commitdiff
* methods/http{s,}.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Mon, 30 Jan 2012 15:26:10 +0000 (16:26 +0100)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Mon, 30 Jan 2012 15:26:10 +0000 (16:26 +0100)
  - 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)

debian/changelog
methods/http.cc
methods/https.cc

index 12abea47d4e43d19eefdd081f3a956e19601c650..69036a945915719b8685e9404d17c673c52c0341 100644 (file)
@@ -9,6 +9,10 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low
       silbings for reinstallation as well (LP: #859188)
   * apt-pkg/contrib/configuration.cc:
     - do not stop parent transversal in FindDir if the value is empty
+  * 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)
 
   [ Steve Langasek ]
   * cmdline/apt-get.cc:
@@ -22,7 +26,7 @@ apt (0.8.16~exp13) UNRELEASED; urgency=low
     - use a signed int instead of short for score calculation as upgrades
       become so big now that it can overflow (Closes: #657732, LP: #917173)
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 30 Jan 2012 13:07:30 +0100
+ -- David Kalnischkies <kalnischkies@gmail.com>  Mon, 30 Jan 2012 16:06:11 +0100
 
 apt (0.8.16~exp12) experimental; urgency=low
 
index b8ed43cd256cb99d07827adb0bff7dc761c553b8..2721b1224e69afd8025aff8b514e4d110c9abc43 100644 (file)
@@ -716,7 +716,19 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
       }
    }
 
-   
+   // 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::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)
+        strcat(Buf,"Accept: text/*\r\n");
+   }
+
    string Req = Buf;
 
    // Check for a partial file
index 6de18b8e09db126e2a41f7055c7d050388da2ce3..4f2d581d26ab544382116761b81fe1849b66da6e 100644 (file)
@@ -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)
    {