mod_python and Content-Type

P

Paul Rudin

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?
 
G

Graham Dumpleton

Paul said:
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
 
P

Paul Rudin

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 :(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

mod_python and css 0
mod_python 4
mod_python and file not found 0
Apache 2.2.3 and mod_python 3.2.10 2
Getting mod_python to Work 1
ZSI + mod_python 0
mod_python help! 1
some problems with mod_python 6

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top