Issue Details (XML | Word | Printable)

Key: MODPYTHON-29
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Nicolas Lehuen
Reporter: Graham Dumpleton
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
mod_python

mod_python.publisher and inbound content_type

Created: 08/Mar/05 06:54 PM   Updated: 14/Feb/06 09:25 AM
Return to search
Component/s: publisher
Affects Version/s: 3.1.4
Fix Version/s: None

Time Tracking:
Not Specified


 Description  « Hide
The mod_python.publisher implementation always decodes form parameters
regardless of whether the method being called can accept any and also ignores
whether the content type is even of a type where form parameters can be
decoded in the first place. This means that it is not possible using the
mod_python.publisher module to implement a method which accepts POST
requests with a inbound content type such as "text/xml". Attempting to do
so yields an error such as:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>501 Method Not Implemented</title>
</head><body>
<h1>Method Not Implemented</h1>
<p>POST to /xmlrpc/service not supported.<br />
</p>
<hr />
<address>Apache/2.0.51 (Unix) mod_python/3.1.4 Python/2.3 Server at localhost Port 8080</address>
</body></html>

The "Method Not Implemented" error in this case is due to FieldStorage
rejecting the content type of "text/xml".

A check could be added to ensure that FieldStorage is only used to decode
form parameters if the content type is appropriate. Ie.,

    if not req.headers_in.has_key("content-type"):
      content_type = "application/x-www-form-urlencoded"
    else:
      content_type = req.headers_in["content-type"]

    if content_type == "application/x-www-form-urlencoded" or \
        content_type[:10] == "multipart/":

      req.form = util.FieldStorage(req,keep_blank_values=1)

Because req.form is passed to util.apply_fs_data(), code where it is called
would need to be changed to pass None instead and util.apply_fs_data()
would need to be modified to see that the argument is None and not do
the field conversion process of stuff in the form etc etc.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.