New submission from Tres Seaver <tsea...@palladion.com>:

Some servers (e.g., wwwsearch.sourceforge.net) apparently send multiple
'Content-Length' headers, which causes setuptools to barf trying to convert
a '<length>, <length>' string to an integer.

This bug breaks installing 'mechanize', which lists wwwsearch.sourceforge.net
as its Download-URL, and therefore causes a bunch of Zope-related tests to fail
(e.g., https://mail.zope.org/pipermail/cmf-tests/2011-March/014576.html ).

The attached patch uses 'headers.getheaders('Content-Length')[0] to use only
the first value found.

----------
assignedto: pje
files: setuptools-multi_content_length.patch
messages: 598
nosy: pje, tseaver
priority: urgent
status: unread
title: [PATCH] Tolerate responses with multiple Content-Length headers
Added file: 
http://bugs.python.org/setuptools/file75/setuptools-multi_content_length.patch

_______________________________________________
Setuptools tracker <setupto...@bugs.python.org>
<http://bugs.python.org/setuptools/issue123>
_______________________________________________
=== modified file 'setuptools/package_index.py'
--- setuptools/package_index.py	2010-02-01 16:42:04 +0000
+++ setuptools/package_index.py	2011-03-23 14:06:46 +0000
@@ -550,7 +550,9 @@
             bs = self.dl_blocksize
             size = -1
             if "content-length" in headers:
-                size = int(headers["Content-Length"])
+                # Some servers return multiple Content-Length headrers :(
+                content_length = headers.getheaders("Content-Length")[0]
+                size = int(content_length)
                 self.reporthook(url, filename, blocknum, bs, size)
             tfp = open(filename,'wb')
             while True:

_______________________________________________
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig

Reply via email to