Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #11757 - Set mimetype when responding with HttpResponseNotModif…

…ied in django.server.static.

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 8a109a7bc8e66548e9c47e3aa0cb5a6ea8c02e34 1 parent 73d636f
@jezdez jezdez authored
Showing with 2 additions and 2 deletions.
  1. +2 −2 django/views/
4 django/views/
@@ -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])
Please sign in to comment.
Something went wrong with that request. Please try again.