Issue #889 resolved

providing config entries to set default response headers

created an issue

It should be possible to set the default response headers. For example one should be able to set default content-type to json by setting content-type for response header for a cherrypy application.

Comments (4)

  1. Anonymous
    response.headers: {'Content-Type': 'application/json'}
    response.headers.Content-Type : "application/json"
    <fumanchu> what do you think of "response.headers.Content-Type" instead?
    <lakin> I like that as the config entry - would that allow you to set ANY 
    header as a default?
    * fumanchu wonders if response.headers: {'Content-Type': 'application/json'} 
    works right now
    <fumanchu> yes, any header
    <lakin> I think it would sorta work but the init would override it?
    <fumanchu> right, it would
    <lakin> I prefer something that allows setting of any header - the 
    former or the latter that you suggested is fine with me
    <fumanchu> but we could make it update instead of replace, I think
    <lakin> yeah
    <fumanchu> maybe both?
    <lakin> in the init we'd need to make a copy of the class-level headers
    <fumanchu> it'll have to be a "smart" config namespace anyway
    <lakin> sure, both would make it more discoverable
    <fumanchu> since headers is a HeaderMap, not just a dict
    <lakin> right
    <lakin> *grin*
     If you provide some hints about where to see examples of custom namespaces
     - or, even if you don't, I might find some time to work on the ticket 
    later this weekend
    <fumanchu> _engine_namespace_handler is at the bottom of _cpconfig
    <lakin> cool
  2. Log in to comment