Issue #423 resolved

[patch] sessionfilter fix for when _cphttptools raises an exception in processHeaders()

anonymous
created an issue

When processHeaders() in _cphttptools.Request raises an exception, the sessionfilter causes a 500 error by trying to access cpy.request._session, which doesn't exist until its before_request_body() method is called. This error occurs regardless of whether the sessionfilter is enabled.

Example: {{{

telnet localhost 8080 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. get / http/1.2

http/1.2 500 Internal error Date: Thu, 29 Dec 2005 04:30:25 GMT Server: CherryPy/2.2.0-beta Content-Length: 1358 Content-Type: text/html <snip /> Traceback: File "/blah/cherrypy/trunk/cherrypy/_cphttptools.py", line 110, in _run applyFilters('before_finalize') File "/blah/cherrypy/trunk/cherrypy/filters/init.py", line 130, in applyFilters method() File "/blah/cherrypy/trunk/cherrypy/filters/sessionfilter.py", line 205, in before_finalize sess = cherrypy.request._session File "/blah/cherrypy/trunk/cherrypy/init.py", line 34, in getattr return getattr(childobject, name) AttributeError: 'Request' object has no attribute '_session' }}}

Fix: {{{ delete line "cherrypy.request._session = EmptyClass()" from the before_request_body() method in sessionfilter.py

add the following lines to the SessionFilter class in sessionfilter.py: def on_start_resource(self): cherrypy.request._session = EmptyClass() }}}

Comments (2)

  1. Log in to comment