diff --git a/.gitignore b/.gitignore index a0e5c6b9..608006ce 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,5 @@ todo.md .hypothesis .coverage + +.idea/ diff --git a/loris/resolver.py b/loris/resolver.py index 9c5c838f..ad311913 100644 --- a/loris/resolver.py +++ b/loris/resolver.py @@ -2,6 +2,7 @@ `resolver` -- Resolve Identifiers to Image Paths ================================================ """ +import cgi from contextlib import closing import glob import json @@ -298,7 +299,8 @@ def cached_file_for_ident(self, ident): def cache_file_extension(self, ident, response): if 'content-type' in response.headers: try: - extension = self.get_format(ident, constants.FORMATS_BY_MEDIA_TYPE[response.headers['content-type']]) + content_type = cgi.parse_header(response.headers['content-type'])[0] + extension = self.get_format(ident, constants.FORMATS_BY_MEDIA_TYPE[content_type]) except KeyError: logger.warn('Your server may be responding with incorrect content-types. Reported %s for ident %s.', response.headers['content-type'], ident) diff --git a/tests/simple_http_resolver_ut.py b/tests/simple_http_resolver_ut.py index 86ac8837..7319e006 100644 --- a/tests/simple_http_resolver_ut.py +++ b/tests/simple_http_resolver_ut.py @@ -63,14 +63,14 @@ def set_responses(self): responses.HEAD, self.identifier_url, status=200, - content_type='image/tiff' + content_type='image/tiff; charset=UTF-8' ) responses.add( responses.GET, self.identifier_url, body='II*\x00\x0c\x00\x00\x00\x80\x00 \x0e\x00\x00\x01\x03\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x01\x03\x00\x01\x00\x00\x00\x01\x00\x00\x00\x02\x01\x03\x00\x01\x00\x00\x00\x08\x00\x00\x00\x03\x01\x03\x00\x01\x00\x00\x00\x05\x00\x00\x00\x06\x01\x03\x00\x01\x00\x00\x00\x03\x00\x00\x00\x11\x01\x04\x00\x01\x00\x00\x00\x08\x00\x00\x00\x15\x01\x03\x00\x01\x00\x00\x00\x01\x00\x00\x00\x16\x01\x03\x00\x01\x00\x00\x00\x08\x00\x00\x00\x17\x01\x04\x00\x01\x00\x00\x00\x04\x00\x00\x00\x1a\x01\x05\x00\x01\x00\x00\x00\xba\x00\x00\x00\x1b\x01\x05\x00\x01\x00\x00\x00\xc2\x00\x00\x00\x1c\x01\x03\x00\x01\x00\x00\x00\x01\x00\x00\x00(\x01\x03\x00\x01\x00\x00\x00\x02\x00\x00\x00@\x01\x03\x00\x00\x03\x00\x00\xca\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00H\x00\x00\x00\x01\x00\x00\x00H\x00\x00\x00\x01\x00\x00\x00\xff`\xe6q\x19\x08\x00\x00\x80\t\x00\x00\x80\n\x00\x00\x80\x0b\x00\x00\x80\x0c\x00\x00\x80\r', status=200, - content_type='image/tiff' + content_type='image/tiff; charset=UTF-8' ) responses.add( responses.HEAD,