]> git.saurik.com Git - apt.git/blobdiff - methods/http.cc
no_proxy environment variable
[apt.git] / methods / http.cc
index 0c44ea461f230a19bc7e95ab44374787e90a2bea..34f2f1af5bebd432cf14c2e9ba4fdad11937582c 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: http.cc,v 1.36 1999/07/18 23:06:56 jgg Exp $
+// $Id: http.cc,v 1.39 1999/10/18 03:18:40 jgg Exp $
 /* ######################################################################
 
    HTTP Aquire Method - This is the HTTP aquire method for APT.
@@ -54,6 +54,7 @@ int HttpMethod::FailFd = -1;
 time_t HttpMethod::FailTime = 0;
 unsigned long PipelineDepth = 10;
 unsigned long TimeOut = 120;
+bool Debug = false;
 
 // CircleBuf::CircleBuf - Circular input buffer                                /*{{{*/
 // ---------------------------------------------------------------------
@@ -288,6 +289,27 @@ bool ServerState::Open()
    else
       Proxy = getenv("http_proxy");
    
+   // Parse no_proxy, a , seperated list of hosts
+   if (getenv("no_proxy") != 0)
+   {
+      const char *Start = getenv("no_proxy");
+      for (const char *Cur = Start; true ; Cur++)
+      {
+        if (*Cur != ',' && *Cur != 0)
+           continue;
+        if (stringcasecmp(ServerName.Host.begin(),ServerName.Host.end(),
+                          Start,Cur) == 0)
+        {
+           Proxy = "";
+           break;
+        }
+        
+        Start = Cur + 1;
+        if (*Cur == 0)
+           break;
+      }         
+   }      
+   
    // Determine what host and port to use based on the proxy settings
    int Port = 0;
    string Host;   
@@ -631,7 +653,9 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
           Base64Encode(Proxy.User + ":" + Proxy.Password) + "\r\n";
 
    Req += "User-Agent: Debian APT-HTTP/1.2\r\n\r\n";
-//   cerr << Req << endl;
+   
+   if (Debug == true)
+      cerr << Req << endl;
 
    Out.Read(Req);
 }
@@ -724,7 +748,7 @@ bool HttpMethod::Go(bool ToFile,ServerState *Srv)
    // Handle commands from APT
    if (FD_ISSET(STDIN_FILENO,&rfds))
    {
-      if (Run(true) != 0)
+      if (Run(true) != -1)
         exit(100);
    }   
        
@@ -939,6 +963,7 @@ bool HttpMethod::Configuration(string Message)
    TimeOut = _config->FindI("Acquire::http::Timeout",TimeOut);
    PipelineDepth = _config->FindI("Acquire::http::Pipeline-Depth",
                                  PipelineDepth);
+   Debug = _config->FindB("Debug::Acquire::http",false);
    
    return true;
 }
@@ -963,8 +988,10 @@ int HttpMethod::Loop()
            return 0;
       }
       
-      // Run messages
-      if (Run(true) != 0)
+      /* Run messages, we can accept 0 (no message) if we didn't
+         do a WaitFd above.. Otherwise the FD is closed. */
+      int Result = Run(true);
+      if (Result != -1 && (Result != 0 || Queue == 0))
         return 100;
 
       if (Queue == 0)