Paul Rudin wrote:
> I'm have a little experiment with mod_python. I'm trying to figure out
> how to get hold of the original Content-Type header.
>
> In my config file I have:
>
> <Directory /var/www/test/atom>
>       AddHandler mod_python .py
>       PythonHandler atomserv
>       PythonDebug On
>           PythonAutoReload On
> </Directory>
>
> The file atomserv.py in that directory has a function called handler
> that gets called as I expect, but on entry to that function
> req.content_type is "text/x-python" whereas my test client sent a
> different Content-Type header.
>
> So, how can I either persuade the apache/mod_python machinery to
> preserve the original content_type, or else how can I get hold of it?

All headers which come from the client are available through the
'headers_in'
attribute of the request object. Eg.

  def handler(req):
    ct = req.headers_in.get('Content-Type')
    ...

The 'content_type' attribute is set by Apache based on its
determination of
what the content type of the response will be based on looking at the
extension type used on the matched resource specified by the URL.

Graham

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to