Created
March 24, 2011 22:20
-
-
Save hltbra/886024 to your computer and use it in GitHub Desktop.
Kelsey Hightower's patch to issue #32 (in github) -- pip crashes when server does not send content-type header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HG changeset patch -- Bitbucket.org | |
# Project pip | |
# URL https://bitbucket.org/khightower/pip/overview | |
# User Kelsey Hightower <kelsey.hightower@gmail.com> | |
# Date 1296967318 18000 | |
# Node ID 1bb3bf439fdb61596b1f28ad32e7ba60e67ff064 | |
# Parent 0542924d062debf8a4b9a8c83da8241411955139 | |
Fixing issue 207 -- pip crashes when server does not send content-type header | |
--- a/pip/download.py | |
+++ b/pip/download.py | |
@@ -427,7 +427,13 @@ def unpack_http_url(link, location, down | |
logger.notify('Using download cache from %s' % target_file) | |
else: | |
resp = _get_response_from_url(target_url, link) | |
- content_type = resp.info()['content-type'] | |
+ if 'content-type' in resp.info(): | |
+ content_type = resp.info()['content-type'] | |
+ else: | |
+ # The HTTP response header did not define the content-type. | |
+ # Set content-type to an empty string which supports the | |
+ # 'lower' attribute required by mimetypes.guess_extension() | |
+ content_type = '' | |
filename = link.filename | |
ext = splitext(filename)[1] | |
if not ext: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment