[mod_python] Raw HTTP Request

Graeme Matthew graeme.matthew at contrado.com.au
Fri Apr 29 20:01:34 EDT 2005


g'day everyone

Can someone please assist or offer some pointers.

I am wanting to get the raw content i.e entire http request as a string 
in mod_python.

The reason being is I want to have a central front controller that can 
accept CGI, SOAP and XMLRPC calls. To handle this I need the request 
content as a string so that I can dispatch to CGI or to an XML handler.

I have done some investigation and I am thinking that the way to go 
would be:

Get Content Length

then do  a

http_string  = request.read(content_length)

Then I can dispatch it to the appropriate controller where for example 
if it is a cgi request then I can simply perform 
cgi.parse_qs(http_string) and if a SOAP request do 
xmlsoap.process(http_string)


If content_type == "html":
    controller.process(http_string)
elif content_type == "xml":
    controller.process(http_string)
else:
    pass
    #handle invalid request type

Any assistance is appreciated


Graeme Matthew
Director
Contrado Solutions PTY LTD
email: graeme.matthew at contrado.com.au
mobile: 0400-872-879



More information about the Mod_python mailing list