How to set a response header based on an argument to a page

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to set a response header based on an argument to a page

benchline

Hi All,

I have a need to create a page that, based on the arguments passed into
it, will return different Content-Type headers (either text/xml or
text/html).

Is this possible in cherrypy currently?  If so, can someone point me in
the right direction?

Thanks,

Paul


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How to set a response header based on an argument to a page

Sylvain Hellegouarch

benchline wrote:
> Hi All,
>
> I have a need to create a page that, based on the arguments passed into
> it, will return different Content-Type headers (either text/xml or
> text/html).
>
> Is this possible in cherrypy currently?  If so, can someone point me in
> the right direction?

Well you simply set the right Content-Type within your page handler.

For instance:
cherrypy.response.headers['Content-Type'] = 'text/xml'

- Sylvain

--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: How to set a response header based on an argument to a page

Robert Brewer
Sylvain wrote:
> benchline wrote:
> > I have a need to create a page that, based on the
> > arguments passed into it, will return different
> > Content-Type headers (either text/xml or text/html).
>
> Well you simply set the right Content-Type within your page handler.
>
> For instance:
> cherrypy.response.headers['Content-Type'] = 'text/xml'

...and if you wanted to go a step further and actually use HTTP the way it was designed, you could switch on the Accept header insted of 'arguments'. See cherrypy.tools.accept in 3.0.


Robert Brewer
System Architect
Amor Ministries
[hidden email]


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

winmail.dat (4K) Download Attachment