From c901051d43e68c2edd91360830b4f279a8896e15 Mon Sep 17 00:00:00 2001
From: Arch Librarian <arch@canonical.com>
Date: Mon, 20 Sep 2004 16:53:22 +0000
Subject: [PATCH] Fixed cisco cacheengine lameness Author: jgg Date: 1999-04-04
 02:02:04 GMT Fixed cisco cacheengine lameness

---
 methods/http.cc | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/methods/http.cc b/methods/http.cc
index 0d84a9dc7..4bd7975a4 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: http.cc,v 1.29 1999/03/15 07:20:41 jgg Exp $
+// $Id: http.cc,v 1.30 1999/04/04 02:02:04 jgg Exp $
 /* ######################################################################
 
    HTTP Aquire Method - This is the HTTP aquire method for APT.
@@ -504,11 +504,22 @@ bool ServerState::HeaderLine(string Line)
 
    string::size_type Pos = Line.find(' ');
    if (Pos == string::npos || Pos+1 > Line.length())
-      return _error->Error("Bad header line");
-   
-   string Tag = string(Line,0,Pos);
-   string Val = string(Line,Pos+1);
+   {
+      // Blah, some servers use "connection:closes", evil.
+      Pos = Line.find(':');
+      if (Pos == string::npos || Pos + 2 > Line.length())
+	 return _error->Error("Bad header line");
+      Pos++;
+   }
 
+   // Parse off any trailing spaces between the : and the next word.
+   string::size_type Pos2 = Pos;
+   while (Pos2 < Line.length() && isspace(Line[Pos2]) != 0)
+      Pos2++;
+      
+   string Tag = string(Line,0,Pos);
+   string Val = string(Line,Pos2);
+   
    if (stringcasecmp(Tag.begin(),Tag.begin()+4,"HTTP") == 0)
    {
       // Evil servers return no version
-- 
2.47.2