Skip to content

Commit

Permalink
Added missing charset to content-type headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdoms committed May 12, 2021
1 parent 0ed30f3 commit dcaf83a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions controllers/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def securityHeaders(self):

def renderTemplate(self, filename, **kwargs):
if filename.endswith('.xml'):
self.set_header('Content-Type', 'application/xml')
self.set_header('Content-Type', 'application/xml; charset=UTF-8')

if self.request.method != 'HEAD':
self.securityHeaders()
Expand All @@ -156,7 +156,7 @@ def renderError(self, status_int, stacktrace=None):
self.renderTemplate("error.html", stacktrace=stacktrace, page_title=page_title)

def renderJSON(self, data):
self.set_header('Content-Type', 'application/json')
self.set_header('Content-Type', 'application/json; charset=UTF-8')
if self.request.method != 'HEAD':
# auto add the xsrf token in to every response
self.set_header('X-Xsrf-Token', self.xsrf_token)
Expand Down Expand Up @@ -190,7 +190,7 @@ def renderCSV(self, rows, filename):
memory_file.close()

# send the file
self.set_header('Content-Type', 'text/csv')
self.set_header('Content-Type', 'text/csv; charset=UTF-8')
# NOTE: setting Content-Length causes "Tried to write more data than Content-Length" from Tornado
# see https://www.tornadoweb.org/en/stable/_modules/tornado/http1connection.html
# self.set_header('Content-Length', str(len(csv_file)))
Expand Down

0 comments on commit dcaf83a

Please sign in to comment.