[Twisted-web] Buffered requests

Peter Hunt floydophone at gmail.com
Thu Nov 4 11:35:34 MST 2004

I'm wondering if there is a way that I can "buffer" a request, store
the output it would normally send to the client in a string, and then
output something different, such as a redirect, to the client.

For example, it'd be nice if it worked like this:

buffered_request.write("<html>Hello %s</html>" %
output = buffered_request.getOutput()
request.write("The output that will be written to the client is:\n " + output)

The end result (in the browser) should be:

The output that will be written to the client is:
200 OK
Content-type: text/plain

<html>Hello world</html>

I've tried playing around with something called "queued", but I'm not
sure if that's what I want. Essentially I just want to capture the
output of a request in a string.

Thanks in advance.

More information about the Twisted-web mailing list