Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 128

Show
Ignore:
Timestamp:
01/13/05 09:04:08
Author:
rdelon
Message:

Improved the way static files are being served

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cphttptools.py

    r124 r128  
    329329 
    330330            cpg.response.headerMap['Last-Modified'] = strModifTime 
    331             f=open(fname, 'rb') 
    332             cpg.response.body = f.read() 
    333             f.close() 
     331            # Set Content-Length and use an iterable (file object) 
     332            #   this way CP won't load the whole file in memory 
     333            cpg.response.headerMap['Content-Length'] = stat[6] 
     334            cpg.response.body = open(fname, 'rb') 
    334335            # Set content-type based on filename extension 
    335336            i = path.rfind('.') 

Hosted by WebFaction

Log in as guest/cpguest to create tickets