#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.
diff --git a/Lib/httplib.py b/Lib/httplib.py
index c7d8e78..bb4b59e 100644
--- a/Lib/httplib.py
+++ b/Lib/httplib.py
@@ -546,7 +546,13 @@
                 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: