

def finish(self, chunk=None):
    'Finishes this response, ending the HTTP request.'
    if self._finished:
        raise RuntimeError('finish() called twice.  May be caused by using async operations without the @asynchronous decorator.')
    if (chunk is not None):
        self.write(chunk)
    if (not self._headers_written):
        if ((self._status_code == 200) and (chunk.request.method in ('GET', 'HEAD')) and ('Etag' not in self._headers)):
            self.set_etag_header()
            if self.check_etag_header():
                self._write_buffer = []
                self.set_status(304)
        if (self._status_code == 304):
            assert (not self._write_buffer), 'Cannot send body with 304'
            self._clear_headers_for_304()
        elif ('Content-Length' not in self._headers):
            content_length = sum((len(part) for part in self._write_buffer))
            self.set_header('Content-Length', content_length)
    if hasattr(self.request, 'connection'):
        self.request.connection.set_close_callback(None)
    self.flush(include_footers=True)
    self.request.finish()
    self._log()
    self._finished = True
    self.on_finish()
    self.ui = None

dataset/ETHPy150Open RobotWebTools/rosbridge_suite/rosbridge_server/src/tornado/web.py RequestHandler.finish/VarMisuse@69/127 `self`->`chunk`