Returning HTTP POST body from CGI module

Stephen shriek at gmx.co.uk
Sat Nov 24 20:08:48 CET 2001


I have a Python CGI script receiving XML data via HTTP POST from 
another company.  Unfortunately, that company doesn't seem to
have implemented the HTTP protocol correctly.

ie. they are currently sending HTTP POST requests of the 
    following format : 

----------------->8-----------------

POST /script.py HTTP/1.1
HOST: www.fubar.com
CONTENT-LENGTH: 66

<vehicle>
   <car>
      <model>Toyota</model>
      <color>Red</color>
   </car>
<vehicle>

----------------->8-----------------

If I understand correctly, the body of a HTTP POST should be 
URL-encoded, right ?  Since they are sending XML data in the 
HTTP body, and it is not URL-encoded, it's not really 
compatible with the CGI module which will be looking for
variable/value pairs.  Is it possible to access the raw 
HTTP header and body from the CGI module instead ? 
Or will I really have to write a socket handler to deal with
this ?

Stephen.



More information about the Python-list mailing list