

def write(self, chunk):
    'Writes the given chunk to the output buffer.\n\n        To write the output to the network, use the flush() method below.\n\n        If the given chunk is a dictionary, we write it as JSON and set\n        the Content-Type of the response to be ``application/json``.\n        (if you want to send JSON as a different ``Content-Type``, call\n        set_header *after* calling write()).\n\n        Note that lists are not converted to JSON because of a potential\n        cross-site security vulnerability.  All JSON output should be\n        wrapped in a dictionary.  More details at\n        http://haacked.com/archive/2009/06/25/json-hijacking.aspx/ and\n        https://github.com/facebook/tornado/issues/1009\n        '
    if self._finished:
        raise RuntimeError('Cannot write() after finish().  May be caused by using async operations without the @asynchronous decorator.')
    if (not isinstance(chunk, (bytes_type, unicode_type, dict))):
        raise TypeError('write() only accepts bytes, unicode, and dict objects')
    if isinstance(chunk, dict):
        chunk = escape.json_encode(chunk)
        self.set_header('Content-Type', 'application/json; charset=UTF-8')
    chunk = utf8(chunk)
    self._write_buffer.append(chunk)

dataset/ETHPy150Open RobotWebTools/rosbridge_suite/rosbridge_server/src/tornado/web.py RequestHandler.write/original