]> granicus.if.org Git - python/commitdiff
Fix sf bug 666219: assertion error in httplib.
authorJeremy Hylton <jeremy@alum.mit.edu>
Sun, 29 Jun 2003 17:55:05 +0000 (17:55 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Sun, 29 Jun 2003 17:55:05 +0000 (17:55 +0000)
The obvious way for this assertion to fail is if the LineAndFileWrapper constructor is called when an empty line.  Raise a BadStatusError before the call.

Lib/httplib.py

index b1712d84bd7f6f8f105533363e6a20118c8773a3..03adb43604bfc8791cbc241527ae94c1d435b571 100644 (file)
@@ -231,6 +231,10 @@ class HTTPResponse:
         line = self.fp.readline()
         if self.debuglevel > 0:
             print "reply:", repr(line)
+        if not line:
+            # Presumably, the server closed the connection before
+            # sending a valid response.
+            raise BadStatusLine(line)
         try:
             [version, status, reason] = line.split(None, 2)
         except ValueError: