[mod_python] AuthHandler and Content-type

mod_python user python at theorb.net
Mon Aug 30 13:49:42 EDT 2004

Peter van Kampen wrote:
> Hi,
> I have this configured apache like this:
> <Directory /var/www/playground/test>
>         SetHandler mod_python
> 	PythonAuthenHandler test
> 	PythonDebug On
> 	require valid-user
> </Directory>
> test.py is simply this:
> from mod_python import apache
> def authenhandler(req):
>     req.user = ""
>     return apache.OK
> Finally there's a file: test.html in the same directory.
> The problem is that now the content_type is text/plain. When I turn of
> mod_python the content_type is text/html (as I want it to be).
> I know I can set req.content_type = "text/html" but I want apache (or
> mod_python) to do that for me... (because the files might not be only
> .html). 

By using the apache Header and RequestHeader directives one can modify 
both the incoming and outgoing headers.  For instance, adding this to 
the <Directory> block above would always force text/html.
	Header set Content-type text/html

You may learn more in the apache manual available here:

Hope that is what you need.
Mike Wright

> Can I do that with mod_python? I noticed there is PythonTypeHandler but the
> documentation is rather scarce.
> TIA,
> PterK

More information about the Mod_python mailing list