(self, chunk: str | bytes | dict | list)
| 290 | raise tornado.httpclient.HTTPError(403) |
| 291 | |
| 292 | def write(self, chunk: str | bytes | dict | list): |
| 293 | # Writing arrays on the top level is ok nowadays. |
| 294 | # http://flask.pocoo.org/docs/0.11/security/#json-security |
| 295 | if isinstance(chunk, list): |
| 296 | chunk = tornado.escape.json_encode(chunk) |
| 297 | self.set_header("Content-Type", "application/json; charset=UTF-8") |
| 298 | super().write(chunk) |
| 299 | |
| 300 | def set_default_headers(self): |
| 301 | super().set_default_headers() |