* methods/http.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Fri, 20 Aug 2010 22:52:59 +0000 (00:52 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Fri, 20 Aug 2010 22:52:59 +0000 (00:52 +0200)
  - some http servers violate HTTP1.1 by not issuing a Reason-Phrase
    (or at least a space after the code) especially for 200, but lets
    be nice and ignore it as we don't need the reason in general

debian/changelog
methods/http.cc

index a08dce9..c2c0b60 100644 (file)
@@ -15,8 +15,12 @@ apt (0.8.0~pre2) UNRELEASED; urgency=low
     - set dir::state::status based at least on dir
   * apt-pkg/deb/dpkgpm.cc:
     - use the InstVer instead of the CurrentVer for the autobit transfer
+  * methods/http.cc:
+    - some http servers violate HTTP1.1 by not issuing a Reason-Phrase
+      (or at least a space after the code) especially for 200, but lets
+      be nice and ignore it as we don't need the reason in general
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Fri, 20 Aug 2010 19:06:29 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Fri, 20 Aug 2010 23:00:54 +0200
 
 apt (0.8.0~pre1) experimental; urgency=low
 
index 9fa74bf..25e31de 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