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

Changeset 1271

Show
Ignore:
Timestamp:
08/23/06 14:38:25
Author:
fumanchu
Message:

Moved the 'methods_with_bodies' feature from config to an attribute of the Request object; use a hook or tool to set it.

Files:

Legend:

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

    r1268 r1271  
    102102    rfile = None 
    103103    process_request_body = True 
     104    methods_with_bodies = ("POST", "PUT") 
    104105    body = None 
    105106    body_read = False 
     
    257258                self.hooks.run('on_start_resource') 
    258259                 
    259                 if self.process_request_body and not self.body_read: 
    260                     # Check path-specific methods_with_bodies. 
    261                     meths = self.config.get("methods_with_bodies", ("POST", "PUT")) 
    262                     self.process_request_body = self.method in meths 
     260                if not self.body_read: 
     261                    if self.process_request_body: 
     262                        if self.method not in self.methods_with_bodies: 
     263                            self.process_request_body = False 
    263264                     
    264                     # Prepare the SizeCheckWrapper for the request body 
    265                     mbs = int(self.config.get('server.max_request_body_size', 
    266                                               100 * 1024 * 1024)) 
    267                     if mbs > 0: 
    268                         self.rfile = http.SizeCheckWrapper(self.rfile, mbs) 
     265                    if self.process_request_body: 
     266                        # Prepare the SizeCheckWrapper for the request body 
     267                        mbs = int(self.config.get('server.max_request_body_size', 
     268                                                  100 * 1024 * 1024)) 
     269                        if mbs > 0: 
     270                            self.rfile = http.SizeCheckWrapper(self.rfile, mbs) 
    269271                 
    270272                self.hooks.run('before_request_body') 
  • trunk/cherrypy/test/test_core.py

    r1263 r1271  
    378378        'server.max_request_header_size': 500, 
    379379        }) 
     380     
     381    def expand_methods(): 
     382        cherrypy.request.methods_with_bodies = ("POST", "PUT", "PROPFIND") 
    380383    appconf = { 
    381384        '/': {'log_access_file': log_access_file}, 
    382         '/method': {'methods_with_bodies': ("POST", "PUT", "PROPFIND")}, 
     385        '/method': {'hooks.on_start_resource': expand_methods}, 
    383386        } 
    384387    cherrypy.tree.mount(root, conf=appconf) 

Hosted by WebFaction

Log in as guest/cpguest to create tickets