Uploaded image for project: 'mod_python'
  1. mod_python
  2. MODPYTHON-29

mod_python.publisher and inbound content_type

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 3.1.4
    • None
    • publisher
    • None

    Description

      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.

      Attachments

        Activity

          People

            nlehuen Nicolas Lehuen
            grahamd Graham Phillip Dumpleton
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: