By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,715 Members | 768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,715 IT Pros & Developers. It's quick & easy.

mod_python and Content-Type

P: n/a

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?
Jan 13 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a

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

Jan 14 '07 #2

P: n/a
"Graham Dumpleton" <gr*****@dscpl.com.auwrites:

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')
...
Thanks - it's even mentioned in the mod_python manual. Don't know how
I missed it :(
Jan 14 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.