[mod_python] How to read raw post in mod_python?

Graham Dumpleton graham.dumpleton at gmail.com
Sat Dec 8 15:54:33 EST 2007


When using mod_python.publisher the POST data is always consumed. It
does this as by definition publisher always parses content for form
parameters. That is does this even when content type isn't form data
is arguable wrong. See:

  https://issues.apache.org/jira/browse/MODPYTHON-29

You would need to add an override for the specific URL in question and
route it to a basic mod_python handler and then you have full control
and thus full access to content of request.

Graham

On 09/12/2007, Marco Lopes <mlopes at orangeway.org> wrote:
> Hi,
>
> I'm giving my first steps in mod_python and I seem to be having some
> problems to get the unprocessed post data.
> I've been trying req.read() but the return result is empty, I tried it
> without parameters, with the content-length and with some value higher than
> the content-length but it still returned empty.
> The content-length in the req.headers_in come with a non-zero value but the
> variable req.clength is always 0.
>
> First I used the following mod_python apache configuration:
>
>     <Directory /var/www/test>
>             AllowOverride AuthConfig
>             Order allow,deny
>             Allow from all
>
>             DirectoryIndex index.py
>             SetHandler mod_python
>             PythonHandler mod_python.publisher
>             PythonDebug On
>     </Directory>
>
>
> Then I found something in the mailling list about a problem that could occur
> with that configuration that could cause strange behaviour leading to empty
> or corrupt data in GET and/or POST data (because of not using the index.py
> file name, this could be an old problem alredy addressed but I can't
> remember the message date) and I tried the following configuration:
>
>     <Directory /var/www/test>
>             AllowOverride AuthConfig
>             Order allow,deny
>             Allow from all
>
>             AddHandler mod_python .py
>             PythonHandler mod_python.publisher
>             PythonDebug On
>     </Directory>
>
>
> The req.read() call continued to return empty.
> I checked the req.form and the POST is there already processed, I'm thinking
> that if I could find a way to tell mod_python not to process the post I
> could then use req.read() to get the raw post.
>
> Can anyone give-me any information that could help me with this?
>
> Thanks,
> Marco Lopes
>
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
>
>


More information about the Mod_python mailing list