web/lib/django/views/static.py
changeset 29 cc9b7e14412b
parent 0 0d40e90630ef
--- a/web/lib/django/views/static.py	Wed May 19 17:43:59 2010 +0200
+++ b/web/lib/django/views/static.py	Tue May 25 02:43:45 2010 +0200
@@ -51,15 +51,15 @@
     if os.path.isdir(fullpath):
         if show_indexes:
             return directory_index(newpath, fullpath)
-        raise Http404, "Directory indexes are not allowed here."
+        raise Http404("Directory indexes are not allowed here.")
     if not os.path.exists(fullpath):
-        raise Http404, '"%s" does not exist' % fullpath
+        raise Http404('"%s" does not exist' % fullpath)
     # Respect the If-Modified-Since header.
     statobj = os.stat(fullpath)
+    mimetype = mimetypes.guess_type(fullpath)[0] or 'application/octet-stream'
     if not was_modified_since(request.META.get('HTTP_IF_MODIFIED_SINCE'),
                               statobj[stat.ST_MTIME], statobj[stat.ST_SIZE]):
-        return HttpResponseNotModified()
-    mimetype = mimetypes.guess_type(fullpath)[0] or 'application/octet-stream'
+        return HttpResponseNotModified(mimetype=mimetype)
     contents = open(fullpath, 'rb').read()
     response = HttpResponse(contents, mimetype=mimetype)
     response["Last-Modified"] = http_date(statobj[stat.ST_MTIME])