Port to 2.7 - issue 10817 - Fix urlretrieve function to raise
ContentTooShortError even when reporthook is None. Patch by Jyrki Pulliainen.
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 1d65ce5..0432ccc 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -257,9 +257,9 @@
                 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)