From 32b8033244baf5fa400a356f7b061156d3454f45 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 21 Feb 2014 12:16:06 -0800 Subject: [PATCH] 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. --- package_cache/server.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 -- 2.26.2