--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -1,3 +1,5 @@
+import mimetypes
+
from pylons import response
from paste.httpheaders import CACHE_CONTROL, EXPIRES
@@ -13,3 +15,15 @@
response.headers.pop('cache-control', None)
response.headers.pop('pragma', None)
response.headers.update(headers)
+
+def guess_mime_type(filename):
+ '''Guess MIME type based on filename.
+ Applies heuristics, tweaks, and defaults in centralized manner.
+ '''
+ # Consider changing to strict=False
+ content_type = mimetypes.guess_type(filename, strict=True)
+ if content_type[0]:
+ content_type = content_type[0]
+ else:
+ content_type = 'application/octet-stream'
+ return content_type