]> git.saurik.com Git - apt.git/blobdiff - methods/http.cc
fix the testcases which were broken by the new space between number and unit
[apt.git] / methods / http.cc
index 5fdc62696d2b2ca46116dfedafb06415051a8935..25e31de9a3126becc17db843f4e4e59a2a1837c5 100644 (file)
@@ -553,8 +553,14 @@ bool ServerState::HeaderLine(string Line)
       // Evil servers return no version
       if (Line[4] == '/')
       {
-        if (sscanf(Line.c_str(),"HTTP/%u.%u %u%[^\n]",&Major,&Minor,
-                   &Result,Code) != 4)
+        int const elements = sscanf(Line.c_str(),"HTTP/%u.%u %u%[^\n]",&Major,&Minor,&Result,Code);
+        if (elements == 3)
+        {
+           Code[0] = '\0';
+           if (Debug == true)
+              clog << "HTTP server doesn't give Reason-Phrase for " << Result << std::endl;
+        }
+        else if (elements != 4)
            return _error->Error(_("The HTTP server sent an invalid reply header"));
       }
       else
@@ -953,6 +959,9 @@ HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
       failure */
    if (Srv->Result < 200 || Srv->Result >= 300)
    {
+      char err[255];
+      snprintf(err,sizeof(err)-1,"HttpError%i",Srv->Result);
+      SetFailReason(err);
       _error->Error("%u %s",Srv->Result,Srv->Code);
       if (Srv->HaveContent == true)
         return ERROR_WITH_CONTENT_PAGE;
@@ -1366,15 +1375,4 @@ bool HttpMethod::AutoDetectProxy()
 }
                                                                        /*}}}*/
 
-int main()
-{
-   setlocale(LC_ALL, "");
-   // ignore SIGPIPE, this can happen on write() if the socket
-   // closes the connection (this is dealt with via ServerDie())
-   signal(SIGPIPE, SIG_IGN);
-
-   HttpMethod Mth;
-   return Mth.Loop();
-}
-