Skip to content

Commit acdeb17

Browse files
committed
fix: if Content-Type header defined, don't overwrite with default
When processing a template, you should be able to set the content-type header using: tal:replace="python:request.client.additional_headers.update( {'Content-Type':'application/vnd.roundup.translation+json'} )" The client used to always overwrite it with the content type derived from the template extension or text/html for unknown extensions. This patch stops the overwriting if the Content-Type is already set in the header. This particular use case was to use an XML document to process a url like: /tracker?@template=translation+json&tokens=Login,Welcome+%s and get back json data of the translated strings. If the file was named '_generic.json' and we used '@template=json' we got application/json returned. For other template names we got text/html.
1 parent 95c49cf commit acdeb17

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

roundup/cgi/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2132,7 +2132,8 @@ def renderContext(self):
21322132
except IndexerQueryError as e:
21332133
result = self.renderError(e.args[0])
21342134

2135-
self.additional_headers['Content-Type'] = pt.content_type
2135+
if 'Content-Type' not in self.additional_headers:
2136+
self.additional_headers['Content-Type'] = pt.content_type
21362137
if self.env.get('CGI_SHOW_TIMING', ''):
21372138
if self.env['CGI_SHOW_TIMING'].upper() == 'COMMENT':
21382139
timings = {'starttag': '<!-- ', 'endtag': ' -->'}

0 commit comments

Comments
 (0)