[mod_python] 411 Length Required for POST

Deron Meranda deron.meranda at gmail.com
Fri Mar 3 15:47:20 EST 2006


On 3/3/06, Jim Gallacher <jpg at jgassociates.ca> wrote:
> If you are not sending a body, just use GET. That way you don't need to
> worry about setting the content type or length. FieldStorage will still
> parse the url of a GET request to grab any parameters.

Even better is to understand the differences between GET and
POST (and PUT, etc.).  They are intended for different semantic
behaviors--notably whether they are idempotent.

After you've chosen the correct method FIRST, then figure out how
you want to encode/format the data/parameters.  It's just that with
the semantics of POST it's rather unusal to use URL-encoding.
Maybe you really meant GET, but you should be sure before
blindly changing the method.

Note you don't have to use either URL encoding or FORM encoding.
If you want something simple to build in Javascript, but which still goes
in the POST request body, look at JSON, http://json.org/ -- there's python
bindings so it would be easy for your mod_python modules to decode
JSON formatted data.

You should probably review RFC 2616 http://www.ietf.org/rfc/rfc2616.txt

A less technical read is:
http://www.faqs.org/faqs/www/cgi-faq/section-37.html
--
Deron Meranda



More information about the Mod_python mailing list