diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2011-10-31 17:35:17 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2011-10-31 17:35:17 (GMT) |
commit | ce260142c6c6eaf32775c4aec283c3a4c921b75c (patch) | |
tree | 6e7766ee8212602dd419064dba553ea491272063 /Lib/urllib | |
parent | 53bcd660122b6604373e5304bd014c41c8ca3e08 (diff) | |
download | cpython-ce260142c6c6eaf32775c4aec283c3a4c921b75c.zip cpython-ce260142c6c6eaf32775c4aec283c3a4c921b75c.tar.gz cpython-ce260142c6c6eaf32775c4aec283c3a4c921b75c.tar.bz2 |
Fix issue 10817 - Fix urlretrieve function to raise ContentTooShortError
even when reporthook is None. Patch by Jyrki Pulliainen.
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/request.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 8ea058f..ca17da5 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1589,9 +1589,9 @@ class URLopener: size = -1 read = 0 blocknum = 0 + if "content-length" in headers: + size = int(headers["Content-Length"]) if reporthook: - if "content-length" in headers: - size = int(headers["Content-Length"]) reporthook(blocknum, bs, size) while 1: block = fp.read(bs) |