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

Changeset 1319

Show
Ignore:
Timestamp:
09/02/06 13:39:10
Author:
fumanchu
Message:

Fix for #535 (Apache re-processes Range headers). _cpmodpy now uses a new "ignore_headers(['Range'])" Tool by default.

Files:

Legend:

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

    r1275 r1319  
    1919        func() 
    2020     
    21     cherrypy.config.update({'log.screen': False}) 
     21    cherrypy.config.update({'log.screen': False, 
     22                            "tools.ignore_headers.on": True, 
     23                            "tools.ignore_headers.headers": ['Range'], 
     24                            }) 
    2225     
    2326    if cherrypy.engine.state == cherrypy._cpengine.STOPPED: 
  • trunk/cherrypy/_cptools.py

    r1311 r1319  
    313313default_toolbox.tidy = Tool('before_finalize', tidy.tidy) 
    314314default_toolbox.nsgmls = Tool('before_finalize', tidy.nsgmls) 
     315default_toolbox.ignore_headers = Tool('before_request_body', cptools.ignore_headers) 
    315316 
    316317 
  • trunk/cherrypy/lib/cptools.py

    r1303 r1319  
    121121                xff = xff.split(',')[-1].strip() 
    122122            request.remote.ip = xff 
     123 
     124 
     125def ignore_headers(headers=('Range',)): 
     126    """Delete request headers whose field names are included in 'headers'. 
     127     
     128    This is a useful tool for working behind certain HTTP servers; 
     129    for example, Apache duplicates the work that CP does for 'Range' 
     130    headers, and will doubly-truncate the response. 
     131    """ 
     132    request = cherrypy.request 
     133    for name in headers: 
     134        if name in request.headers: 
     135            del request.headers[name] 
    123136 
    124137 
  • trunk/cherrypy/test/modpy.py

    r1317 r1319  
    111111        import cherrypy 
    112112        cherrypy.config.update({ 
    113             "log.error.file": os.path.join(curdir, "test.log"), 
     113            "log.error_file": os.path.join(curdir, "test.log"), 
    114114            "environment": "production", 
    115115            }) 

Hosted by WebFaction

Log in as guest/cpguest to create tickets