Ticket #367 (defect)
Opened 3 years ago
Last modified 3 years ago
Default error pages should (re)set response headers
Status: closed (fixed)
| Reported by: | polaar | Assigned to: | rdelon |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | CherryPy code | Keywords: | |
| Cc: |
When an error page is returned, some response headers that could have already been set may not be appropriate anymore. Example:
import cherrypy
class Root:
@cherrypy.expose
def index(self):
cherrypy.response.headerMap['Content-type'] = 'text/plain'
return doSomethingWrong()
cherrypy.root = Root()
if __name__ == '__main__':
cherrypy.server.start()
In this example, the errorpage (which is HTML) will be served with a content-type of text/plain. The same problem will presumably occur with other headers too.
Response headers should be modified match to the actual response. (I suppose for errorpages, they could be reset completely)
Change History
10/24/05 17:31:25: Modified by fumanchu
10/24/05 17:56:53: Modified by polaar
I mean for the builtin (didn't know what it was called). Maybe the example wasn't clear enough. doSomethingWrong was just a dummy name to indicate that there was happening something that would trigger an error. (and it actually does, because it will throw a NameError?). Maybe it would have been better if I had written:
doSomethingWrong() return 'hello world'
If it's still not clear: try running the example, looking at it in a browser, and you'll get the idea.
10/24/05 18:27:13: Modified by fumanchu
Hm. It seems that HTTPRedirect sets the Content-Type header, but that behavior didn't make it into HTTPError. That needs to be fixed (although be advised it may raise Yet Another XMLRPC Conflict).
Regarding other headers, however, I'm not 100% sure that the spec for "may not be appropriate" can be accurately defined. Some header-rewrites may be application-specific. In classic Wally-Reflector style, I'm going to ask for a complete list of all such header-rewrite-rules before recommending we build that in. ;)
10/31/05 15:53:32: Modified by fumanchu
- status changed from new to closed.
- resolution set to fixed.
Fixed in [771]. Does HTTPRedirect need the same header logic?


Do you mean for the builtin HTTPError object? Or are you envisioning some way for the developer to signal to the core that doSomethingWrong returns "an error response"?