diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2011-04-04 12:39:21 +0000 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2011-04-04 12:39:21 +0000 |
| commit | 4d3ab063b1b36bd4fb9a75d26b6c883d632aef0e (patch) | |
| tree | be0b8d8d685d68e476bd43bb030ad8f8dce99c30 | |
| parent | 1c7a9a403a8cdeb300423bec569febe4e52241ba (diff) | |
Fixed #15613: Don't send content-length headers for non-regular files. Thanks to jaylett.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16014 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/views/static.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/django/views/static.py b/django/views/static.py index c058cd3ff8..0caef8c9d3 100644 --- a/django/views/static.py +++ b/django/views/static.py @@ -5,6 +5,7 @@ during development, and SHOULD NOT be used in a production setting. import mimetypes import os +import stat import posixpath import re import urllib @@ -58,7 +59,8 @@ def serve(request, path, document_root=None, show_indexes=False): return HttpResponseNotModified(mimetype=mimetype) response = HttpResponse(open(fullpath, 'rb').read(), mimetype=mimetype) response["Last-Modified"] = http_date(statobj.st_mtime) - response["Content-Length"] = statobj.st_size + if stat.S_ISREG(statobj.st_mode): + response["Content-Length"] = statobj.st_size if encoding: response["Content-Encoding"] = encoding return response |
