1. Dave Abrahams
  2. pip-misc

Commits

Dave Abrahams  committed 3b795dc

Explicitly request the identity encoding as insurance against
http://bugs.python.org/issue8732

  • Participants
  • Parent commits 82582ae
  • Branches default

Comments (0)

Files changed (2)

File pip/index.py

View file
 from Queue import Empty as QueueEmpty
 from pip.log import logger
 from pip.util import Inf, path_to_url2, url_to_path
-from pip.util import normalize_name, splitext
+from pip.util import normalize_name, splitext, urlopen
 from pip.exceptions import DistributionNotFound
 
 __all__ = ['PackageFinder']
                                 cache.set_is_archive(url)
                             return None
             logger.debug('Getting page %s' % url)
-            resp = urllib2.urlopen(url)
+            resp = urlopen(url)
             real_url = resp.geturl()
             headers = resp.info()
             inst = cls(resp.read(), real_url, headers)

File pip/util.py

View file
     if not cr:
         cr = (os.environ.get('LINES', 25), os.environ.get('COLUMNS', 80))
     return int(cr[1]), int(cr[0])
+
+# Insurance against "creative" interpretation of the RFC:
+# http://bugs.python.org/issue8732
+def urlopen(url):
+    if isinstance(url, basestring):
+        url = urllib2.Request(url, headers={'Accept-encoding':'identity'})
+    return urllib2.urlopen(url)