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
This commit is contained in:
Jannis Leidel 2010-01-09 20:04:33 +00:00
parent 73d636f740
commit 8a109a7bc8
1 changed files with 2 additions and 2 deletions

View File

@ -56,10 +56,10 @@ def serve(request, path, document_root=None, show_indexes=False):
raise Http404, '"%s" does not exist' % fullpath raise Http404, '"%s" does not exist' % fullpath
# Respect the If-Modified-Since header. # Respect the If-Modified-Since header.
statobj = os.stat(fullpath) 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'), if not was_modified_since(request.META.get('HTTP_IF_MODIFIED_SINCE'),
statobj[stat.ST_MTIME], statobj[stat.ST_SIZE]): statobj[stat.ST_MTIME], statobj[stat.ST_SIZE]):
return HttpResponseNotModified() return HttpResponseNotModified(mimetype=mimetype)
mimetype = mimetypes.guess_type(fullpath)[0] or 'application/octet-stream'
contents = open(fullpath, 'rb').read() contents = open(fullpath, 'rb').read()
response = HttpResponse(contents, mimetype=mimetype) response = HttpResponse(contents, mimetype=mimetype)
response["Last-Modified"] = http_date(statobj[stat.ST_MTIME]) response["Last-Modified"] = http_date(statobj[stat.ST_MTIME])