X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/0fa3c89c9e5c2c61a70c714ef8e4ac9d2b7d6ae1..ced53a741a3a11da53920ee0bb86adb4e3a7c931:/methods/http.cc

diff --git a/methods/http.cc b/methods/http.cc
index 71a02e53a..ed6e3517d 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -3,7 +3,7 @@
 // $Id: http.cc,v 1.59 2004/05/08 19:42:35 mdz Exp $
 /* ######################################################################
 
-   HTTP Acquire Method - This is the HTTP aquire method for APT.
+   HTTP Acquire Method - This is the HTTP acquire method for APT.
    
    It uses HTTP/1.1 and many of the fancy options there-in, such as
    pipelining, range, if-range and so on. 
@@ -33,25 +33,21 @@
 #include <apt-pkg/error.h>
 #include <apt-pkg/hashes.h>
 #include <apt-pkg/netrc.h>
+#include <apt-pkg/strutl.h>
 
+#include <stddef.h>
+#include <stdlib.h>
+#include <sys/select.h>
+#include <cstring>
 #include <sys/stat.h>
 #include <sys/time.h>
-#include <utime.h>
 #include <unistd.h>
-#include <signal.h>
 #include <stdio.h>
 #include <errno.h>
-#include <string.h>
-#include <climits>
 #include <iostream>
-#include <map>
-
-// Internet stuff
-#include <netdb.h>
 
 #include "config.h"
 #include "connect.h"
-#include "rfc2553emu.h"
 #include "http.h"
 
 #include <apti18n.h>
@@ -62,7 +58,7 @@ unsigned long long CircleBuf::BwReadLimit=0;
 unsigned long long CircleBuf::BwTickReadData=0;
 struct timeval CircleBuf::BwReadTick={0,0};
 const unsigned int CircleBuf::BW_HZ=10;
- 
+
 // CircleBuf::CircleBuf - Circular input buffer				/*{{{*/
 // ---------------------------------------------------------------------
 /* */
@@ -88,8 +84,8 @@ void CircleBuf::Reset()
    {
       delete Hash;
       Hash = new Hashes;
-   }   
-};
+   }
+}
 									/*}}}*/
 // CircleBuf::Read - Read from a FD into the circular buffer		/*{{{*/
 // ---------------------------------------------------------------------
@@ -97,8 +93,6 @@ void CircleBuf::Reset()
    is non-blocking.. */
 bool CircleBuf::Read(int Fd)
 {
-   unsigned long long BwReadMax;
-
    while (1)
    {
       // Woops, buffer is full
@@ -106,7 +100,7 @@ bool CircleBuf::Read(int Fd)
 	 return true;
 
       // what's left to read in this tick
-      BwReadMax = CircleBuf::BwReadLimit/BW_HZ;
+      unsigned long long const BwReadMax = CircleBuf::BwReadLimit/BW_HZ;
 
       if(CircleBuf::BwReadLimit) {
 	 struct timeval now;
@@ -476,7 +470,7 @@ bool HttpServerState::WriteResponse(const std::string &Data)		/*{{{*/
    return Out.Read(Data);
 }
 									/*}}}*/
-bool HttpServerState::IsOpen()						/*{{{*/
+APT_PURE bool HttpServerState::IsOpen()					/*{{{*/
 {
    return (ServerFd != -1);
 }
@@ -487,16 +481,11 @@ bool HttpServerState::InitHashes(FileFd &File)				/*{{{*/
    In.Hash = new Hashes;
 
    // Set the expected size and read file for the hashes
-   if (StartPos >= 0)
-   {
-      File.Truncate(StartPos);
-
-      return In.Hash->AddFD(File, StartPos);
-   }
-   return true;
+   File.Truncate(StartPos);
+   return In.Hash->AddFD(File, StartPos);
 }
 									/*}}}*/
-Hashes * HttpServerState::GetHashes()					/*{{{*/
+APT_PURE Hashes * HttpServerState::GetHashes()				/*{{{*/
 {
    return In.Hash;
 }
@@ -735,7 +724,7 @@ void HttpMethod::SendReq(FetchItem *Itm)
    }
 
    // If we ask for uncompressed files servers might respond with content-
-   // negotation which lets us end up with compressed files we do not support,
+   // negotiation 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.
@@ -798,7 +787,6 @@ bool HttpMethod::Configuration(string Message)
    PipelineDepth = _config->FindI("Acquire::http::Pipeline-Depth",
 				  PipelineDepth);
    Debug = _config->FindB("Debug::Acquire::http",false);
-   AutoDetectProxyCmd = _config->Find("Acquire::http::ProxyAutoDetect");
 
    // Get the proxy to use
    AutoDetectProxy();
@@ -811,6 +799,11 @@ bool HttpMethod::Configuration(string Message)
 /* */
 bool HttpMethod::AutoDetectProxy()
 {
+   // option is "Acquire::http::Proxy-Auto-Detect" but we allow the old
+   // name without the dash ("-")
+   AutoDetectProxyCmd = _config->Find("Acquire::http::Proxy-Auto-Detect",
+                                      _config->Find("Acquire::http::ProxyAutoDetect"));
+
    if (AutoDetectProxyCmd.empty())
       return true;