Ticket #7535: static.py.patch

File static.py.patch, 905 bytes (added by Kevin Hunter <hunteke@…, 16 years ago)

Content-Encoding patch for django.views.static.serve

  • static.py

     
    5959    if not was_modified_since(request.META.get('HTTP_IF_MODIFIED_SINCE'),
    6060                              statobj[stat.ST_MTIME], statobj[stat.ST_SIZE]):
    6161        return HttpResponseNotModified()
    62     mimetype = mimetypes.guess_type(fullpath)[0] or 'application/octet-stream'
     62    mimetype = ('application/octet-stream', 'identity')
     63    mimetype = mimetypes.guess_type(fullpath) or mimetype
    6364    contents = open(fullpath, 'rb').read()
    64     response = HttpResponse(contents, mimetype=mimetype)
     65    response = HttpResponse(contents, mimetype=mimetype[0])
    6566    response["Last-Modified"] = http_date(statobj[stat.ST_MTIME])
     67    response["Content-Encoding"] = mimetype[1]
    6668    response["Content-Length"] = len(contents)
    6769    return response
    6870
Back to Top