mirror of
https://github.com/django/django.git
synced 2025-10-29 00:26:07 +00:00
Fixed #5596 -- Changed the static view for the development server so that Django doesn't crash if somebody tries to serve a 200MB file. Patch from eibaan.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6939 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -59,10 +59,11 @@ def serve(request, path, document_root=None, show_indexes=False):
|
||||
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]
|
||||
mimetype = mimetypes.guess_type(fullpath)[0] or 'application/octet-stream'
|
||||
contents = open(fullpath, 'rb').read()
|
||||
response = HttpResponse(contents, mimetype=mimetype)
|
||||
response["Last-Modified"] = http_date(statobj[stat.ST_MTIME])
|
||||
response["Content-Length"] = len(contents)
|
||||
return response
|
||||
|
||||
DEFAULT_DIRECTORY_INDEX_TEMPLATE = """
|
||||
|
||||
Reference in New Issue
Block a user