summaryrefslogtreecommitdiff
path: root/django/views/static.py
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2010-01-17 22:10:37 +0000
committerJannis Leidel <jannis@leidel.info>2010-01-17 22:10:37 +0000
commit8eaffeac8aa02e3196a520ccf9fc5be960f9b8ef (patch)
tree2e421f06c1430029bd772abaa79ed03d2df10439 /django/views/static.py
parent0216255632138df9bc7761d3c7a819c1f0c53a43 (diff)
[1.1.X] Fixed #11757 - Set mimetype when responding with HttpResponseNotModified in django.server.static.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12240 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/views/static.py')
-rw-r--r--django/views/static.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/django/views/static.py b/django/views/static.py
index 8355950fe0..32feee8b6e 100644
--- a/django/views/static.py
+++ b/django/views/static.py
@@ -56,10 +56,10 @@ def serve(request, path, document_root=None, show_indexes=False):
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])