Ticket #2378 (closed defect: fixed)
General content_type ticket.
|Reported by:||jorge.vargas||Owned by:|
#2280 explains that @expose(content_type="foo/bar') should be the "default way" of doing this. This is the current behavior in both 2.0.x and 2.1.x.
However #2263 raises the issue of modifying the content type "at runtime" in the case the pylons way of doing it does not work therefore we are using a flag (CUSTOM_CONTENT_TYPE) to prevent it being overwritten. The underlying problem regarding this is under investigation, but it appears to be a trashing of the response object, therefore the correct code:
@expose() def stats(self): pylons.request['Content-Type'] = 'text/csv' return '1,2,3'
Does not work with 2.x and the corresponding must be used:
@expose(content_type=CUSTOM_CONTENT_TYPE) def stats(self): pylons.request['Content-Type'] = 'text/csv' return '1,2,3'