[mod_python] Input filter content-length problem

Amos Latteier amos at latteier.com
Tue Oct 9 18:34:54 EDT 2007


Hi,

I'm creating an input filter to rewrite POSTed form data before
handling. It works great with one exception:

  * My filter changes the length of the request body (since it writes
more than it reads), but I cannot figure out how to change the
Content-Length header to match.

So the program that handles for form data sees the changes that my
input filter makes, but it sees the original Content-Length header,
and thus misses some of the data that my filter adds to the request
body.

I've tried changing the content length by doing:

filter.req.headers_in['Content-Length'] = str(len(my_new_request_body))

before I make any calls to filter.write(). However this doesn't affect
the Content-Length header.

I'd be grateful for any suggestions. Thanks!

-Amos


More information about the Mod_python mailing list