[mod_python] Output filters and 4xx error codes

Andrew Ryan andrewr at collab.net
Tue Dec 16 15:24:15 EST 2008

We have a mod_python tool which uses a FixupHandler to do some reverse
proxying and inline-rewriting (for the general idea, see Graham's example in
http://www.modpython.org/pipermail/mod_python/2006-March/020507.html). In
the handler, we register an output filter, which does the inspecting and
rewriting of content.

This works great as long as the response code sent back is 2xx or 3xx. But
in the case of a 4xx error code, the output filter doesn't run. Instead it
seems to trigger the proxy server's "ErrorDocument" setting. This is
problematic, since we'd like to see the real server's error page, not the
default one from the reverse proxy server.

As far as I can tell from inspecting the request object, the fixuphandler
never sees the returned content, only the incoming request. And the
outputfilter is the only place that the outgoing content is seen. If it
isn't run, well, I don't see any other chance to modify the content that
gets sent back to the client.

Sounds like this person was having a similar problem, but there is no
mention of a solution:
0710020850i3b2a0a25wd005f85350526ffa at mail.gmail.com%3E
He was using mod_proxy though, which has the ProxyErrorOverride option. I
don't think there's an equivalent in mod_python, or something similar, but
I'm not sure.

I was hoping someone else here had seen this problem and could offer a


More information about the Mod_python mailing list