cope with weird Content-Length values returned from servers by
authorJeremy Hylton <jeremy@alum.mit.edu>
Thu, 14 Sep 2000 20:34:27 +0000 (20:34 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Thu, 14 Sep 2000 20:34:27 +0000 (20:34 +0000)
ignoring them; e.g. Zope sometimes returns 13497L

Lib/httplib.py

index eac59e38b03273ffb6c3dcf7e3d912b696142ae7..1fe358e0b947effd4bbc514958a3b6859d234afd 100644 (file)
@@ -166,7 +166,10 @@ class HTTPResponse:
         # NOTE: RFC 2616, S4.4, #3 says we ignore this if tr_enc is "chunked"
         length = self.msg.getheader('content-length')
         if length and not self.chunked:
-            self.length = int(length)
+            try:
+                self.length = int(length)
+            except ValueError:
+                self.length = None
         else:
             self.length = None