| 116 | cherrypy.tools.rotator = cherrypy.Tool('before_finalize', Rotator()) |
| 117 | |
| 118 | def stream_handler(next_handler, *args, **kwargs): |
| 119 | actual = cherrypy.request.config.get('tools.streamer.arg') |
| 120 | assert actual == 'arg value' |
| 121 | cherrypy.response.output = o = io.BytesIO() |
| 122 | try: |
| 123 | next_handler(*args, **kwargs) |
| 124 | # Ignore the response and return our accumulated output |
| 125 | # instead. |
| 126 | return o.getvalue() |
| 127 | finally: |
| 128 | o.close() |
| 129 | cherrypy.tools.streamer = cherrypy._cptools.HandlerWrapperTool( |
| 130 | stream_handler) |
| 131 | |