X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/dc4002d8c3c687e6614d01b34e4b6aa929411ea9..29925560efccf3f5801a122f6061e2cf2046c955:/methods/http.cc

diff --git a/methods/http.cc b/methods/http.cc
index 1833f41ef..068d26978 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 Aquire Method - This is the HTTP aquire method for APT.
+   HTTP Acquire Method - This is the HTTP aquire 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. 
@@ -44,6 +44,7 @@
 // Internet stuff
 #include <netdb.h>
 
+#include "config.h"
 #include "connect.h"
 #include "rfc2553emu.h"
 #include "http.h"
@@ -57,7 +58,7 @@ time_t HttpMethod::FailTime = 0;
 unsigned long PipelineDepth = 10;
 unsigned long TimeOut = 120;
 bool Debug = false;
-
+URI Proxy;
 
 unsigned long CircleBuf::BwReadLimit=0;
 unsigned long CircleBuf::BwTickReadData=0;
@@ -714,7 +715,7 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
       Req += string("Authorization: Basic ") + 
           Base64Encode(Uri.User + ":" + Uri.Password) + "\r\n";
    
-   Req += "User-Agent: Ubuntu APT-HTTP/1.3\r\n\r\n";
+   Req += "User-Agent: Debian APT-HTTP/1.3 ("VERSION")\r\n\r\n";
    
    if (Debug == true)
       cerr << Req << endl;
@@ -995,7 +996,6 @@ bool HttpMethod::Fetch(FetchItem *)
 
    // Queue the requests
    int Depth = -1;
-   bool Tail = false;
    for (FetchItem *I = Queue; I != 0 && Depth < (signed)PipelineDepth; 
 	I = I->Next, Depth++)
    {
@@ -1007,8 +1007,6 @@ bool HttpMethod::Fetch(FetchItem *)
       if (Server->Comp(I->Uri) == false)
 	 break;
       if (QueueBack == I)
-	 Tail = true;
-      if (Tail == true)
       {
 	 QueueBack = I->Next;
 	 SendReq(I,Server->Out);
@@ -1070,7 +1068,6 @@ int HttpMethod::Loop()
 	 delete Server;
 	 Server = new ServerState(Queue->Uri,this);
       }
-      
       /* If the server has explicitly said this is the last connection
          then we pre-emptively shut down the pipeline and tear down 
 	 the connection. This will speed up HTTP/1.0 servers a tad
@@ -1167,8 +1164,25 @@ int HttpMethod::Loop()
 	       URIDone(Res);
 	    }
 	    else
-	       Fail(true);
+		{
+		  if (Server->ServerFd == -1)
+		  {
+			  FailCounter++;
+			  _error->Discard();
+			  Server->Close();
 	    
+			  if (FailCounter >= 2)
+			  {
+				  Fail(_("Connection failed"),true);
+				  FailCounter = 0;
+			  }
+	    
+			  QueueBack = Queue;
+		  }
+		  else
+			  Fail(true);
+		}
+
 	    break;
 	 }