Checks if the provided status code falls in the Client or Server error range of HTTP statuses
@param int $statusCode the status code to check
@return bool TRUE if it falls into the Client or Server error range, FALSE if not
175420
public static function isError(int $statusCode): bool
    {
        return ($statusCode >= HttpStatus::CLIENT_ERROR) && ($statusCode < HttpStatus::SERVER_ERROR_END);
    }
133422
protected static function filterStatus($code)
    {
        if (! is_integer($code) || $code < StatusCode::STATUS_CODE_MIN || $code > StatusCode::STATUS_CODE_MAX) {
            throw new InvalidArgumentException(sprintf(
                'Invalid status code provided; must be an integer between %d and %d, inclusive; received %s',
                StatusCode::STATUS_CODE_MIN,
                StatusCode::STATUS_CODE_MAX,
                (is_object($code) ? get_class($code) : gettype($code))
            ));
        }

        return $code;
    }
1299647
protected function getCodeResponse($statusCode)
    {
        $this->checkParameters();

        /** @var ResponsesInterface $responses */
        $responses = $this->getIntegration()->getFromContainer(ResponsesInterface::class);
        $outputMediaType = $this->codecMatcher->getEncoderRegisteredMatchedType();

        return $responses->getResponse($statusCode, $outputMediaType, null, $this->supportedExtensions);
    }
769713
public function onBeforeHTTPError($statusCode, $request)
    {
        if (Director::is_ajax()) {
            return;
        }
        $response = ErrorPage::response_for($statusCode);
        if ($response) {
            throw new HTTPResponse_Exception($response, $statusCode);
        }
    }
768885
public function statusCodeEquals($code)
    {
        $actual = $this->session->getStatusCode();
        $message = sprintf('Current response status code is %d, but %d expected.', $actual, $code);

        $this->assert(intval($code) === intval($actual), $message);
    }
1358633
public function setStatus($statusCode)
    {
        if ($this->statusCode === null) {
            $this->statusCode = $statusCode;
            $this->response->setStatusCode($statusCode);
        }
    }
1176861
public function response($statusCode = null)
        {
            $response = $this->factory(__NAMESPACE__ . '\Response');

            if (is_numeric($statusCode)) {
                $response->status($statusCode);
            }

            return $response;
        }
1124881
protected function validateCode($code)
    {
        if (is_integer($code)) {
            return true;
        }

        // Plug it back in and see what we get
        if (is_string($code)) {
            return $this->set($code);
        }

        if (is_array($code)) {
            return $this->validateCodeArray($code);
        }

        return false;
    }
135887
public static function validateCloseCode($code)
    {
        return !($code < 1000 || //Not used
            $code > 5000 || //Invalid
            ($code > 1015 && $code < 3000) || //Range 1000-2999 is reserved for protocol, but currently there are no codes above 1015
            $code === 1004 || //Reserved
            $code === self::CODE_NO_STATUS || //Reserved (internal app usage)
            $code === self::CODE_ABNORMAL || //Reserved (internal app usage)
            ($code > 1011 && $code <= 1015) //Not defined by RFC, but from reserved range (exc. 1015 is reserved for app int. use)
        );
    }
848689
public function setStatusCode(int $statusCode): self
    {
        if (!array_key_exists($statusCode, Response::$statusTexts)) {
            $this->internalServerError('Invalid status code in ' . __METHOD__, Response::$statusTexts);
        }

        $this->statusCode = $statusCode;

        return $this;
    }
1280152
public static function isInformational(int $statusCode): bool
    {
        return ($statusCode >= HttpStatus::INFORMATIONAL) && ($statusCode < HttpStatus::SUCCESSFUL);
    }
1072510
private function isError(int $statusCode): bool
    {
        if ($this->statusCodeValidator) {
            return call_user_func($this->statusCodeValidator, $statusCode);
        }

        return $statusCode >= 400 && $statusCode < 600;
    }
292131
protected function validateResponse($statusCode) {
        switch($statusCode) {
            case 204:
                throw new Exceptions\RateLimitException('Too many requests');
            case 403:
                throw new Exceptions\InvalidApiKeyException(sprintf('Key %s is invalid', $this->_apiKey));
            default:
                return;
        }
    }
1079338
public function getErrorResponse($errors, int $statusCode = self::HTTP_BAD_REQUEST, array $headers = [])
    {
        if (\is_iterable($errors) === true) {
            /** @var iterable $errors */
            $content = $this->getEncoder()->encodeErrors($errors);
        } else {
            \assert($errors instanceof ErrorInterface);
            $content = $this->getEncoder()->encodeError($errors);
        }

        return $this->createJsonApiResponse($content, $statusCode, $headers, true);
    }
1299729
public function setStatusCode($statusCode, $text = null)
    {
        // Fallback status code message if missing
        if (! empty($text)) {
            $statusText = $text;
        } elseif (! empty(self::$statusTexts[$statusCode])) {
            $statusText = self::$statusTexts[$statusCode];
        } else {
            $statusText = 'Undefined code';
        }

        // Set status code and text
        $this->statusCode = $statusCode;
        $this->statusText = $statusText;

        // Validate status code
        if ($this->isInvalid()) {
            throw new InvalidArgumentException(sprintf('The HTTP status code "%s" is not valid.', $statusCode));
        }

        return $this;
    }
511297
public function isRedirection(int $code): bool
    {
        return $this->statusExists($code) && ($this->extractFirstDigit($code) == self::CLASS_REDIRECTION);
    }
218204
public function isServerError(int $code): bool
    {
        return $this->statusExists($code) && ($this->extractFirstDigit($code) == self::CLASS_SERVER_ERROR);
    }