Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Minor optimization in the static serve view.

  • Loading branch information...
commit 57c6617c92959856e8cacd809f0e29f57df4f318 1 parent 9893fa1
@aaugustin aaugustin authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 django/views/static.py
View
7 django/views/static.py
@@ -58,12 +58,13 @@ def serve(request, path, document_root=None, show_indexes=False):
raise Http404(_('"%(path)s" does not exist') % {'path': fullpath})
# Respect the If-Modified-Since header.
statobj = os.stat(fullpath)
- mimetype, encoding = mimetypes.guess_type(fullpath)
- mimetype = mimetype or 'application/octet-stream'
if not was_modified_since(request.META.get('HTTP_IF_MODIFIED_SINCE'),
statobj.st_mtime, statobj.st_size):
return HttpResponseNotModified()
- response = CompatibleStreamingHttpResponse(open(fullpath, 'rb'), content_type=mimetype)
+ content_type, encoding = mimetypes.guess_type(fullpath)
+ content_type = content_type or 'application/octet-stream'
+ response = CompatibleStreamingHttpResponse(open(fullpath, 'rb'),
+ content_type=content_type)
response["Last-Modified"] = http_date(statobj.st_mtime)
if stat.S_ISREG(statobj.st_mode):
response["Content-Length"] = statobj.st_size

0 comments on commit 57c6617

Please sign in to comment.
Something went wrong with that request. Please try again.