X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/0837bd25607acd90944a4bfded58d582371ba112..af8425c54cd10adc8377670cc017845ab921d735:/methods/http.cc diff --git a/methods/http.cc b/methods/http.cc index f014193a0..34f2f1af5 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: http.cc,v 1.34 1999/05/29 03:25:03 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; @@ -305,7 +327,7 @@ bool ServerState::Open() } // Connect to the remote server - if (Connect(Host,Port,"http",ServerFd,TimeOut,Owner) == false) + if (Connect(Host,Port,"http",80,ServerFd,TimeOut,Owner) == false) return false; return true; @@ -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); } @@ -643,7 +667,8 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out) bool HttpMethod::Go(bool ToFile,ServerState *Srv) { // Server has closed the connection - if (Srv->ServerFd == -1 && Srv->In.WriteSpace() == false) + if (Srv->ServerFd == -1 && (Srv->In.WriteSpace() == false || + ToFile == false)) return false; fd_set rfds,wfds,efds; @@ -678,7 +703,7 @@ bool HttpMethod::Go(bool ToFile,ServerState *Srv) int MaxFd = FileFD; if (MaxFd < Srv->ServerFd) MaxFd = Srv->ServerFd; - + // Select struct timeval tv; tv.tv_sec = TimeOut; @@ -723,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); } @@ -938,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; } @@ -962,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) @@ -1016,7 +1044,7 @@ int HttpMethod::Loop() if (FailCounter >= 2) { - Fail("Connection timed out",true); + Fail("Connection failed",true); FailCounter = 0; }