| 449 | | if cherrypy.response.timed_out: |
|---|
| 450 | | raise cherrypy.TimeoutError() |
|---|
| 451 | | |
|---|
| 452 | | if self.app is None: |
|---|
| 453 | | raise cherrypy.NotFound() |
|---|
| 454 | | |
|---|
| 455 | | self.hooks = HookMap(self.hookpoints) |
|---|
| 456 | | self.get_resource(path_info) |
|---|
| 457 | | self.tool_up() |
|---|
| 458 | | self.hooks.run('on_start_resource') |
|---|
| 459 | | |
|---|
| 460 | | if not self.body_read: |
|---|
| | 443 | try: |
|---|
| | 444 | if cherrypy.response.timed_out: |
|---|
| | 445 | raise cherrypy.TimeoutError() |
|---|
| | 446 | |
|---|
| | 447 | if self.app is None: |
|---|
| | 448 | raise cherrypy.NotFound() |
|---|
| | 449 | |
|---|
| | 450 | if not self.headers_read: |
|---|
| | 451 | # Get the 'Host' header, so we can do HTTPRedirects properly. |
|---|
| | 452 | self.process_headers() |
|---|
| | 453 | |
|---|
| | 454 | self.hooks = HookMap(self.hookpoints) |
|---|
| | 455 | self.get_resource(path_info) |
|---|
| | 456 | self.tool_up() |
|---|
| | 457 | |
|---|
| | 458 | self.hooks.run('on_start_resource') |
|---|
| | 459 | |
|---|
| | 460 | if not self.body_read: |
|---|
| | 461 | if self.process_request_body: |
|---|
| | 462 | if self.method not in self.methods_with_bodies: |
|---|
| | 463 | self.process_request_body = False |
|---|
| | 464 | |
|---|
| | 465 | if self.process_request_body: |
|---|
| | 466 | # Prepare the SizeCheckWrapper for the request body |
|---|
| | 467 | mbs = cherrypy.server.max_request_body_size |
|---|
| | 468 | if mbs > 0: |
|---|
| | 469 | self.rfile = http.SizeCheckWrapper(self.rfile, mbs) |
|---|
| | 470 | |
|---|
| | 471 | self.hooks.run('before_request_body') |
|---|
| 465 | | if self.process_request_body: |
|---|
| 466 | | # Prepare the SizeCheckWrapper for the request body |
|---|
| 467 | | mbs = cherrypy.server.max_request_body_size |
|---|
| 468 | | if mbs > 0: |
|---|
| 469 | | self.rfile = http.SizeCheckWrapper(self.rfile, mbs) |
|---|
| 470 | | |
|---|
| 471 | | self.hooks.run('before_request_body') |
|---|
| 472 | | if self.process_request_body: |
|---|
| 473 | | self.process_body() |
|---|
| 474 | | |
|---|
| 475 | | self.hooks.run('before_main') |
|---|
| 476 | | if self.handler: |
|---|
| 477 | | self.handler() |
|---|
| 478 | | self.hooks.run('before_finalize') |
|---|
| 479 | | cherrypy.response.finalize() |
|---|
| 480 | | except (cherrypy.HTTPRedirect, cherrypy.HTTPError), inst: |
|---|
| 481 | | inst.set_response() |
|---|
| 482 | | self.hooks.run('before_finalize') |
|---|
| 483 | | cherrypy.response.finalize() |
|---|
| 484 | | finally: |
|---|
| 485 | | self.hooks.run('on_end_resource') |
|---|
| | 475 | self.hooks.run('before_main') |
|---|
| | 476 | if self.handler: |
|---|
| | 477 | self.handler() |
|---|
| | 478 | self.hooks.run('before_finalize') |
|---|
| | 479 | cherrypy.response.finalize() |
|---|
| | 480 | except (cherrypy.HTTPRedirect, cherrypy.HTTPError), inst: |
|---|
| | 481 | inst.set_response() |
|---|
| | 482 | self.hooks.run('before_finalize') |
|---|
| | 483 | cherrypy.response.finalize() |
|---|
| | 484 | finally: |
|---|
| | 485 | self.hooks.run('on_end_resource') |
|---|
| | 486 | except cherrypy.InternalRedirect: |
|---|
| | 487 | raise |
|---|
| | 488 | except: |
|---|
| | 489 | if self.throw_errors: |
|---|
| | 490 | raise |
|---|
| | 491 | self.handle_error(sys.exc_info()) |
|---|