code: public static void bailResponse(HttpContext cx, HttpResponse response) throws IOException, HttpException {
          HttpServerConnection conn = getConnection(cx);
          conn.sendResponseHeader(response);
          conn.sendResponseEntity(response);
          conn.flush();
      }
docs: Send and flush the response object over the current connection and close the connection
  @param cx The context
  @param response The response object
  @throws IOException if an I/O error occurs
  @throws HttpException if a http error occurs