Просмотр исходного кода

add config setting for User-Agent in http and https to the Acquire group,
thanks Timothy J. Miller! (Closes: #355782)

David Kalnischkies лет назад: 16
Родитель
Сommit
9f542bae2b
5 измененных файлов с 18 добавлено и 3 удалено
  1. 3 0
      debian/changelog
  2. 6 1
      doc/apt.conf.5.xml
  3. 3 0
      doc/examples/configure-index
  4. 2 1
      methods/http.cc
  5. 4 1
      methods/https.cc

+ 3 - 0
debian/changelog

@@ -94,6 +94,9 @@ apt (0.7.25) UNRELEASED; urgency=low
     - rewrite to be able to handle even big patch files
     - rewrite to be able to handle even big patch files
     - adopt optional mmap+iovec patch from Morten Hustveit
     - adopt optional mmap+iovec patch from Morten Hustveit
       (Closes: #463354) which should speed up a bit. Thanks!
       (Closes: #463354) which should speed up a bit. Thanks!
+  * methods/http{,s}.cc
+    - add config setting for User-Agent to the Acquire group,
+      thanks Timothy J. Miller! (Closes: #355782)
 
 
   [ Chris Leick ]
   [ Chris Leick ]
   * doc/ various manpages:
   * doc/ various manpages:

+ 6 - 1
doc/apt.conf.5.xml

@@ -275,7 +275,12 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
      <para>The used bandwidth can be limited with <literal>Acquire::http::Dl-Limit</literal>
      <para>The used bandwidth can be limited with <literal>Acquire::http::Dl-Limit</literal>
      which accepts integer values in kilobyte. The default value is 0 which deactivates
      which accepts integer values in kilobyte. The default value is 0 which deactivates
      the limit and tries uses as much as possible of the bandwidth (Note that this option implicit
      the limit and tries uses as much as possible of the bandwidth (Note that this option implicit
-     deactivates the download from multiple servers at the same time.)</para></listitem>
+     deactivates the download from multiple servers at the same time.)</para>
+
+     <para><literal>Acquire::http::User-Agent</literal> can be used to set a different
+     User-Agent for the http download method as some proxies allow access for clients
+     only if the client uses a known identifier.</para>
+     </listitem>
      </varlistentry>
      </varlistentry>
 
 
      <varlistentry><term>https</term>
      <varlistentry><term>https</term>

+ 3 - 0
doc/examples/configure-index

@@ -191,6 +191,7 @@ Acquire
     Max-Age "86400";     // 1 Day age on index files
     Max-Age "86400";     // 1 Day age on index files
     No-Store "false";    // Prevent the cache from storing archives    
     No-Store "false";    // Prevent the cache from storing archives    
     Dl-Limit "7";        // 7Kb/sec maximum download rate
     Dl-Limit "7";        // 7Kb/sec maximum download rate
+    User-Agent "Debian APT-HTTP/1.3";
   };
   };
 
 
   // HTTPS method configuration:
   // HTTPS method configuration:
@@ -204,6 +205,8 @@ Acquire
         CaPath  "/etc/ssl/certs";
         CaPath  "/etc/ssl/certs";
         Verify-Host" "true";
         Verify-Host" "true";
         AllowRedirect  "true";
         AllowRedirect  "true";
+
+        User-Agent "Debian APT-CURL/1.0";
   };
   };
 
 
   ftp
   ftp

+ 2 - 1
methods/http.cc

@@ -731,7 +731,8 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
       Req += string("Authorization: Basic ") + 
       Req += string("Authorization: Basic ") + 
           Base64Encode(Uri.User + ":" + Uri.Password) + "\r\n";
           Base64Encode(Uri.User + ":" + Uri.Password) + "\r\n";
    }
    }
-   Req += "User-Agent: Debian APT-HTTP/1.3 ("VERSION")\r\n\r\n";
+   Req += "User-Agent: " + _config->Find("Acquire::http::User-Agent",
+		"Debian APT-HTTP/1.3 ("VERSION")") + "\r\n\r\n";
    
    
    if (Debug == true)
    if (Debug == true)
       cerr << Req << endl;
       cerr << Req << endl;

+ 4 - 1
methods/https.cc

@@ -211,7 +211,10 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
       curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, dlLimit);
       curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, dlLimit);
 
 
    // set header
    // set header
-   curl_easy_setopt(curl, CURLOPT_USERAGENT,"Debian APT-CURL/1.0 ("VERSION")");
+   curl_easy_setopt(curl, CURLOPT_USERAGENT,
+	_config->Find("Acquire::https::User-Agent",
+		_config->Find("Acquire::http::User-Agent",
+			"Debian APT-CURL/1.0 ("VERSION")")));
 
 
    // set timeout
    // set timeout
    int timeout = _config->FindI("Acquire::http::Timeout",120);
    int timeout = _config->FindI("Acquire::http::Timeout",120);