From: W. Trevor King Date: Fri, 21 Feb 2014 20:16:06 +0000 (-0800) Subject: server: Add a fallback MIME type (application/octet-stream) X-Git-Tag: v0.2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=32b8033244baf5fa400a356f7b061156d3454f45;p=package-cache.git server: Add a fallback MIME type (application/octet-stream) Avoid: Traceback (most recent call last): File "/.../wsgiref/handlers.py", line 137, in run self.result = application(self.environ, self.start_response) File "/.../site-packages/package_cache/server.py", line 50, in __call__ environ=environ, start_response=start_response) File "/.../site-packages/package_cache/server.py", line 69, in _serve_request path=cache_path, environ=environ, start_response=start_response) File "/.../site-packages/package_cache/server.py", line 124, in _serve_file start_response('200 OK', list(headers.items())) File "/.../wsgiref/handlers.py", line 226, in start_response self.headers = self.headers_class(headers) File "/.../wsgiref/headers.py", line 39, in __init__ self._convert_string_type(v) File "/.../wsgiref/headers.py", line 46, in _convert_string_type " of type str (got {0})".format(repr(value))) AssertionError: Header names/values must be of type str (got None) for portage-20140220.tar.xz.md5sum. --- diff --git a/package_cache/server.py b/package_cache/server.py index 2dfbc1e..f64b62b 100644 --- a/package_cache/server.py +++ b/package_cache/server.py @@ -143,8 +143,9 @@ class Server (object): mimetype, charset = _mimetypes.guess_type(url=path) if charset: return '{}; charset={}'.format(mimetype, charset) - else: + elif mimetype: return mimetype + return 'application/octet-stream' def _get_last_modified(self, path): """Last-Modified value per RFC 2616