Fix HTML detection (#6394)

Some servers report a content-type header instead of Content-Type.
This commit is contained in:
Michael Kuhn 2018-01-03 04:21:36 +01:00 committed by Adam J. Stewart
parent d2c3b3884b
commit 01bec7976b

View File

@ -276,7 +276,8 @@ def fetch(self):
# Check if we somehow got an HTML file rather than the archive we
# asked for. We only look at the last content type, to handle
# redirects properly.
content_types = re.findall(r'Content-Type:[^\r\n]+', headers)
content_types = re.findall(r'Content-Type:[^\r\n]+', headers,
flags=re.IGNORECASE)
if content_types and 'text/html' in content_types[-1]:
tty.warn("The contents of ",
(self.archive_file if self.archive_file is not None