Skip to content

Commit 8a109a7

Browse files
committed
Fixed #11757 - Set mimetype when responding with HttpResponseNotModified in django.server.static.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12141 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 73d636f commit 8a109a7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

django/views/static.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ def serve(request, path, document_root=None, show_indexes=False):
5656
raise Http404, '"%s" does not exist' % fullpath
5757
# Respect the If-Modified-Since header.
5858
statobj = os.stat(fullpath)
59+
mimetype = mimetypes.guess_type(fullpath)[0] or 'application/octet-stream'
5960
if not was_modified_since(request.META.get('HTTP_IF_MODIFIED_SINCE'),
6061
statobj[stat.ST_MTIME], statobj[stat.ST_SIZE]):
61-
return HttpResponseNotModified()
62-
mimetype = mimetypes.guess_type(fullpath)[0] or 'application/octet-stream'
62+
return HttpResponseNotModified(mimetype=mimetype)
6363
contents = open(fullpath, 'rb').read()
6464
response = HttpResponse(contents, mimetype=mimetype)
6565
response["Last-Modified"] = http_date(statobj[stat.ST_MTIME])

0 commit comments

Comments
 (0)