Stop application, send HTTP status

@param int    $code
@param string $msg
@return void
554295
public static function stop($code, $msg = null)
    {
        Response::status($code, false) && self::trigger('changestatus', array($code, $msg));

        if (self::$state < 4) {
            self::$state = 4;
            self::trigger('finish');
        }

        exit;
    }
524444
private function log_exit( $response, $code ) {
		$json_encode_flags = 128 | 64;

		error_log( json_encode( $response, $json_encode_flags ) );

		/**
		 * Action hook after processing REST process.
		 *
		 * @since 8.6.0
		 *
		 * @param array $response
		 * @param int   $code     HTTP response.
		 */
		do_action( 'github_updater_post_rest_process_request', $response, $code );

		unset( $response['success'] );
		if ( 200 === $code ) {
			wp_die( wp_send_json_success( $response, $code ) );
		} else {
			wp_die( wp_send_json_error( $response, $code ) );
		}
	}
1037726
public function outputStatus($code, $message = null)
    {
        $this->addHeader($code)->sendHeaders();

        if (isset($message)) {
            echo $message;
        }

        exit;
    }
369149
public function delete($code) {
        $service = self::get($code);

        $deleteResult = Manager::delete($service->getId());
        if (!$deleteResult->isSuccess()) {
            $this->throwException(
                __METHOD__,
                'Error deleting delivery service [%s]: %s',
                $code,
                implode('; ', $deleteResult->getErrorMessages())
            );
        }
    }
851915
public function close($fd, $code = self::CLOSE_NORMAL, $reason = '')
    {
        $this->send($fd, pack('n', $code).$reason, self::OPCODE_CONNECTION_CLOSE);
        $this->log("server close connection[$fd]. reason: $reason, close_code = $code");
        return $this->server->close($fd);
    }
105193
protected function close(NetworkConnectionInterface $conn, $code = 400)
    {
        $response = new HttpResponse($code);

        $conn->send($response);
        $conn->close();
    }
600841
public function setStatusCode($code, $message)
  {
    $this->meta->statusCode = $code;
    $this->meta->statusMessage = $message;
  }
621520
public function badRequest($msg = '', $errorCode = null, $headers = [])
    {
        return $this->getErrorResponse($msg, $errorCode, self::HTTP_BAD_REQUEST, $headers);
    }
354706
public function abort(int $code, string $message = '', array $headers = [])
    {
        if ($code == 404) {
            throw new \Cygnite\Exception\Http\HttpNotFoundException($message);
        }

        throw new \Cygnite\Exception\Http\HttpException($code, $message, null, $headers);
    }
291696
public static function output($data = null, $msg = '', $code = 0)
    {
        if (!$code) {
            echo json_encode([
                'code' => 0,
                'msg' => $msg,
                'data' => $data,
            ], JSON_UNESCAPED_UNICODE);
        } else {
            echo json_encode([
                'code' => $code,
                'msg' => $msg ? $msg : '未知错误',
            ], JSON_UNESCAPED_UNICODE);
        }
    }
285641
private function halt(string $status, string $reason): void
    {
        header('HTTP/1.0 '. $status);
        header('Connection: close');
        header('Content-Type: none');

        $xHaltMessage = sprintf('X-Halt: Reason=%s, Ip=%s, Url:%s', $reason,
            Util::getClientIp(), Util::getCurrentUrl());

        header($xHaltMessage);
        header_remove('X-Powered-By');

        $this->logger->logFail(new AppException($xHaltMessage));

        print '<!---->';

        exit(1); // boom!
    }
480097
public function sendAll($msg) : void
    {
        foreach ($this->subscriptionTable->findActive() as $row)
        {
            $this->sendNotification($row, $msg, false);
        }

        if ($flush)
        {
            $this->flush();
        }
    }
827081
public function abort($code = 500, $message = '', array $headers = [])
    {
        $this->response->status($code);

        foreach ($headers as $key => $value) {
            $this->response->addHeader($key, $value);
        }

        if ($message == null) {
            $message = 'The trial was suspended.';
        }

        throw new HttpException($message);
    }
448740
protected function respondWithError(
        $message = 'Bad Request',
        $code = SymfonyResponse::HTTP_BAD_REQUEST,
        array $headers = []
    ) {
        return abort($code, $message, $headers);
    }
499031
public function status($code = 200)
    {
        if (!isset(self::$codes[$code])) {
            return false;
        }
        $this->header($code . ' ' . self::$codes[$code]);
        return true;
    }
1152249
public function send($code, $body = '')
    {
        if (!isset($this->codes[$code])) {
            $statusCode = 500;
            $body = 'API attempted to return an unknown HTTP status.';
        }
        // if the body wasn't defined, default to the inbuilt response
        if (!$body) $body = $this->codes[$code];
        header('HTTP/1.1 ' . $code . ' ' . $this->codes[$code]);
        header('Content-type: application/json');
        echo json_encode($body);
        exit;
    }
1326155
public function abort($code, $message='')
	{
		switch ($code)
		{
			case 404:
				throw new NotFoundException($message, $code);
			break;

			case 403:
				throw new NotAuthorizedException($message, $code);
			break;

			default:
				throw new RuntimeException($message, $code);
			break;
		}
	}