--- /depot/packages/python-2.3.5/lib/python2.3/httplib.py 2005-06-12 19:07:44.000000000 -0400 +++ hacked-httplib.py 2006-07-24 15:42:29.000000000 -0400 @@ -411,6 +411,7 @@ return s def _read_chunked(self, amt): + print "_read_chunked(amt=%r)" % amt assert self.chunked != _UNKNOWN chunk_left = self.chunk_left value = '' @@ -420,10 +421,21 @@ while True: if chunk_left is None: line = self.fp.readline() + if line == '': + # perhaps this is a minor protocol violation that we + # can simply ignore (web browsers seem to) + raise HTTPException("invalid HTTP chunking: " + "found EOF when expecting chunk size") + i = line.find(';') if i >= 0: line = line[:i] # strip chunk-extensions - chunk_left = int(line, 16) + print "got line %r: it must be a chunk length" % line + try: + chunk_left = int(line, 16) + except ValueError: + raise HTTPException("invalid HTTP chunking: " + "expected chunk size, got %r" % line) if chunk_left == 0: break if amt is None: