summaryrefslogtreecommitdiffstats
path: root/Lib/httplib.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-02-24 13:08:18 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-02-24 13:08:18 (GMT)
commita612dc02ced728f553dcc91ca557a2a8b7fa0ca6 (patch)
tree62b717da0813ba63b61537d380ea923a1e657b3d /Lib/httplib.py
parent8e21a3cf059aa8195716f6e7d3bfd0602daca6f1 (diff)
downloadcpython-a612dc02ced728f553dcc91ca557a2a8b7fa0ca6.zip
cpython-a612dc02ced728f553dcc91ca557a2a8b7fa0ca6.tar.gz
cpython-a612dc02ced728f553dcc91ca557a2a8b7fa0ca6.tar.bz2
Merged revisions 61034-61036,61038-61048 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r61034 | georg.brandl | 2008-02-24 01:03:22 +0100 (Sun, 24 Feb 2008) | 4 lines #900744: If an invalid chunked-encoding header is sent by a server, httplib will now raise IncompleteRead and close the connection instead of raising ValueError. ........ r61035 | georg.brandl | 2008-02-24 01:14:24 +0100 (Sun, 24 Feb 2008) | 2 lines #1627: httplib now ignores negative Content-Length headers. ........ r61039 | andrew.kuchling | 2008-02-24 03:39:15 +0100 (Sun, 24 Feb 2008) | 1 line Remove stray word ........ r61040 | neal.norwitz | 2008-02-24 03:40:58 +0100 (Sun, 24 Feb 2008) | 3 lines Add a little info to the 3k deprecation warnings about what to use instead. Suggested by Raymond Hettinger. ........ r61041 | facundo.batista | 2008-02-24 04:17:21 +0100 (Sun, 24 Feb 2008) | 4 lines Issue 1742669. Now %d accepts very big float numbers. Thanks Gabriel Genellina. ........ r61046 | neal.norwitz | 2008-02-24 08:21:56 +0100 (Sun, 24 Feb 2008) | 5 lines Get ctypes working on the Alpha (Tru64). The problem was that there were two module_methods and the one used depended on the order the modules were loaded. By making the test module_methods static, it is not exported and the correct version is picked up. ........ r61048 | neal.norwitz | 2008-02-24 09:27:49 +0100 (Sun, 24 Feb 2008) | 1 line Fix typo of hexidecimal ........
Diffstat (limited to 'Lib/httplib.py')
-rw-r--r--Lib/httplib.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py
index 638a92b..de27c17 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -448,7 +448,12 @@ class HTTPResponse:
try:
self.length = int(length)
except ValueError:
- pass
+ self.length = None
+ else:
+ if self.length < 0: # ignore nonsensical negative lengths
+ self.length = None
+ else:
+ self.length = None
# does the body have a fixed length? (of zero)
if (status == NO_CONTENT or status == NOT_MODIFIED or
@@ -569,7 +574,13 @@ class HTTPResponse:
i = line.find(b";")
if i >= 0:
line = line[:i] # strip chunk-extensions
- chunk_left = int(line, 16)
+ try:
+ chunk_left = int(line, 16)
+ except ValueError:
+ # close the connection as protocol synchronisation is
+ # probably lost
+ self.close()
+ raise IncompleteRead(value)
if chunk_left == 0:
break
if amt is None: