Ticket #7535: static.py.2.patch
File static.py.2.patch, 936 bytes (added by , 16 years ago) |
---|
-
static.py
59 59 if not was_modified_since(request.META.get('HTTP_IF_MODIFIED_SINCE'), 60 60 statobj[stat.ST_MTIME], statobj[stat.ST_SIZE]): 61 61 return HttpResponseNotModified() 62 mimetype = mimetypes.guess_type(fullpath)[0] or 'application/octet-stream' 62 63 mimetype = mimetypes.guess_type(fullpath) 64 encoding = mimetype[1] or None 65 mimetype = mimetype[0] or 'application/octet-stream' 66 63 67 contents = open(fullpath, 'rb').read() 64 68 response = HttpResponse(contents, mimetype=mimetype) 69 65 70 response["Last-Modified"] = http_date(statobj[stat.ST_MTIME]) 71 if encoding: 72 response["Content-Encoding"] = encoding 66 73 response["Content-Length"] = len(contents) 74 67 75 return response 68 76 69 77 DEFAULT_DIRECTORY_INDEX_TEMPLATE = """