[mod_python] util.FieldStorage wrong about method restrictions

Nic James Ferrier nferrier at tapsellferrier.co.uk
Sun Aug 13 18:28:31 EDT 2006


My version of mod_python (Debian package 3.1.3-3) says this in
util.py:

        # always process GET-style parameters
        if req.args:
            pairs = parse_qsl(req.args, keep_blank_values)
            for pair in pairs:
                file = cStringIO.StringIO(pair[1])
                self.list.append(Field(pair[0], file, "text/plain", {},
                                       None, {}))

        if req.method == "POST" or req.method == "PUT":

            try:
                clen = int(req.headers_in["content-length"])
            except (KeyError, ValueError):
                # absent content-length is not acceptable
                raise apache.SERVER_RETURN, apache.HTTP_LENGTH_REQUIRED

The current version says something similar.

This is wrong. Or at least restictive.

I noticed this because I am PUTting the representation of a resource
as application/x-www-form-urlencoded and I wasn't allowed to do that
using FieldStorage.

Here's a patch:

--- /usr/lib/python2.3/site-packages/mod_python/util.py~
+++ /usr/lib/python2.3/site-packages/mod_python/util.py
@@ -96,7 +96,7 @@
                 self.list.append(Field(pair[0], file, "text/plain", {},
                                        None, {}))
 
-        if req.method == "POST":
+        if req.method == "POST" or req.method == "PUT":
 
             try:
                 clen = int(req.headers_in["content-length"])



-- 
Nic Ferrier
http://www.tapsellferrier.co.uk   for all your tapsell ferrier needs


More information about the Mod_python mailing list