[mod_python] POSTed form fields?

Dr. L.A. Timochouk L.A.Timochouk at ukc.ac.uk
Thu Aug 17 01:31:43 EST 2000


The request object does not contain parsed (or even unparsed) POSTed
fields, so you need to read and parse them yourself:

(1) get the total length of the POSTed data from the "Content-length"
    header (available through the "headers_in" table in the request
    object);

(2) read the data in using the "read" method on the req object; NB:
    in mod_python 2.4.1, "read" can return a shorter data chunk than
    requested ("short read"); a patch had been submitted which
    rectifies the problem; alternatively you can do multiple "read"s
    until you get the whole length of your data;

(3) then you can parse the contents splitting it into key=value
    pairs separated by "&"s. There are some subtleties like multiple
    fields with the same name, file submission by POST,etc, to take
    care about.

Hope it will help,

Leonid Timochouk
Computing Laboratory
University of Kent at Canterbury
England




More information about the Mod_python mailing list