diff options
author | Georg Brandl <georg@python.org> | 2008-02-24 00:03:22 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-02-24 00:03:22 +0000 |
commit | 2363503074a3f1c2dbe934bed0c865d326e34c1a (patch) | |
tree | 5d9a22409e0fb92e604f0758a0d7a1425ce9363c /Lib/httplib.py | |
parent | 5e8e6d2454258d76611444a7260f05094f66d205 (diff) | |
download | cpython-git-2363503074a3f1c2dbe934bed0c865d326e34c1a.tar.gz |
#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.
Diffstat (limited to 'Lib/httplib.py')
-rw-r--r-- | Lib/httplib.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/httplib.py b/Lib/httplib.py index c7d8e781df..bb4b59e701 100644 --- a/Lib/httplib.py +++ b/Lib/httplib.py @@ -546,7 +546,13 @@ class HTTPResponse: i = line.find(';') 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: |