]> git.saurik.com Git - apt.git/blobdiff - methods/http.cc
Configurable max values to use with dpkg
[apt.git] / methods / http.cc
index 0c520b33c232bc4d349a0b91415b4ae6a1080a31..4521197edaa24ee654f413e64846c925e4454fb2 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: http.cc,v 1.50 2001/03/06 07:15:29 jgg Exp $
+// $Id: http.cc,v 1.54 2002/04/18 05:09:38 jgg Exp $
 /* ######################################################################
 
    HTTP Aquire Method - This is the HTTP aquire method for APT.
@@ -37,6 +37,8 @@
 #include <signal.h>
 #include <stdio.h>
 #include <errno.h>
+#include <string.h>
+#include <iostream>
 
 // Internet stuff
 #include <netdb.h>
@@ -46,6 +48,7 @@
 #include "http.h"
 
                                                                        /*}}}*/
+using namespace std;
 
 string HttpMethod::FailFile;
 int HttpMethod::FailFd = -1;
@@ -138,7 +141,7 @@ void CircleBuf::FillOut()
       unsigned long Sz = LeftRead();
       if (OutQueue.length() - StrPos < Sz)
         Sz = OutQueue.length() - StrPos;
-      memcpy(Buf + (InP%Size),OutQueue.begin() + StrPos,Sz);
+      memcpy(Buf + (InP%Size),OutQueue.c_str() + StrPos,Sz);
       
       // Advance
       StrPos += Sz;
@@ -357,7 +360,7 @@ int ServerState::RunHeaders()
       {
         string::const_iterator J = I;
         for (; J != Data.end() && *J != '\n' && *J != '\r';J++);
-        if (HeaderLine(string(I,J-I)) == false)
+        if (HeaderLine(string(I,J)) == false)
            return 2;
         I = J;
       }
@@ -499,7 +502,7 @@ bool ServerState::HeaderLine(string Line)
    string Tag = string(Line,0,Pos);
    string Val = string(Line,Pos2);
    
-   if (stringcasecmp(Tag.begin(),Tag.begin()+4,"HTTP") == 0)
+   if (stringcasecmp(Tag.c_str(),Tag.c_str()+4,"HTTP") == 0)
    {
       // Evil servers return no version
       if (Line[4] == '/')
@@ -723,7 +726,11 @@ bool HttpMethod::Go(bool ToFile,ServerState *Srv)
    tv.tv_usec = 0;
    int Res = 0;
    if ((Res = select(MaxFd+1,&rfds,&wfds,0,&tv)) < 0)
+   {
+      if (errno == EINTR)
+        return true;
       return _error->Errno("select","Select failed");
+   }
    
    if (Res == 0)
    {
@@ -1109,7 +1116,7 @@ int HttpMethod::Loop()
            // Send status to APT
            if (Result == true)
            {
-              Res.MD5Sum = Server->In.Hash->MD5.Result();             
+              Res.TakeHashes(*Server->In.Hash);
               URIDone(Res);
            }
            else
@@ -1135,6 +1142,9 @@ int HttpMethod::Loop()
         // Hard internal error, kill the connection and fail
         case 5:
         {
+           delete File;
+           File = 0;
+
            Fail();
            RotateDNS();
            Server->Close();
@@ -1172,3 +1182,5 @@ int main()
    
    return Mth.Loop();
 }
+
+