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
This commit is contained in:
parent
1c7a9a403a
commit
4d3ab063b1
|
@ -5,6 +5,7 @@ during development, and SHOULD NOT be used in a production setting.
|
||||||
|
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
|
import stat
|
||||||
import posixpath
|
import posixpath
|
||||||
import re
|
import re
|
||||||
import urllib
|
import urllib
|
||||||
|
@ -58,7 +59,8 @@ def serve(request, path, document_root=None, show_indexes=False):
|
||||||
return HttpResponseNotModified(mimetype=mimetype)
|
return HttpResponseNotModified(mimetype=mimetype)
|
||||||
response = HttpResponse(open(fullpath, 'rb').read(), mimetype=mimetype)
|
response = HttpResponse(open(fullpath, 'rb').read(), mimetype=mimetype)
|
||||||
response["Last-Modified"] = http_date(statobj.st_mtime)
|
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:
|
if encoding:
|
||||||
response["Content-Encoding"] = encoding
|
response["Content-Encoding"] = encoding
|
||||||
return response
|
return response
|
||||||
|
|
Loading…
Reference in New Issue