def METHOD_NAME(self, f):
    if f.done() and not f.cancelled():
        ex = f.exception()
        if ex:
            response = [b'HTTP/1.0 400 Bad Request']
            response.append(b'Content-Length: 0')
            response.append(b'Connection: close')
            response.append(b'')
            response.append(b'')
            self.writer.write(CRLF.join(response))
            self.ws.close_connection()