Assert the HTTP response code

@param int $code The HTTP response code
@throws AssertionFailedException
@return void

@Then the response code is :code
187154
public function assertResponseCodeIs($code) {
        $this->requireResponse();

        try {
            Assertion::same(
                $actual = $this->response->getStatusCode(),
                $expected = $this->validateResponseCode($code),
                sprintf('Expected response code %d, got %d.', $expected, $actual)
            );
        } catch (AssertionFailure $e) {
            throw new AssertionFailedException($e->getMessage());
        }
    }
1305403
public function setStatusCode($code)
    {
        // set status code
        $this->statusCode = $code;

        // lookup reason phrase by code and set
        $this->setStatusReasonPhrase(HttpProtocol::getStatusReasonPhraseByCode($code));
    }
255990
protected function createErrorResponse($code)
    {
        $response = new HTTPResponse('', $code);

        // Show message in dev
        if (!Director::isLive()) {
            $response->setBody($response->getStatusDescription());
        }

        return $response;
    }
1268986
protected function isReturncodeValid(int $code): bool {
    	try {
        	$reflection = new \ReflectionClass('\\' . __NAMESPACE__ . '\\interfaces\\NagiosCodes');
        	return in_array($code, $reflection->getConstants());
		} catch (\ReflectionException $exception) {
    		return false;
		}
    }
1188419
protected function validateStatusCode($statusCode) : void
	{
		if (! \is_int($statusCode))
		{
			throw new \InvalidArgumentException('HTTP status-code must be an integer');
		}
		else if (! ($statusCode >= 100 && $statusCode <= 599))
		{
			throw new \InvalidArgumentException(\sprintf('The given status-code "%d" is not valid', $statusCode));
		}
	}
927704
protected function error($code)
    {
        $this->sendFrame('c' . json_encode([$code, isset($this->errors[$code]) ? $this->errors[$code] : null]));
    }
528449
public function assertionHandler($file, $line, $code)
    {
        if ($this->convertAssertionErrorsToExceptions) {
          
          $exception = new ErrorException('Assertion Failed - Code[ '.$code.' ]', 0, null, $file, $line);
    
          if ($this->throwAssertionExceptions) {
              throw $exception;
          } else {
              $this->fb($exception);
          }
        
        } else {
            $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file,'Line'=>$line));
        }
    }
1346461
public static function sendResponseCode($code)
    {
        $messages = array(
            200 => 'Ok',
            204 => 'No Response',
            301 => 'Moved Permanently',
            302 => 'Found',
            304 => 'Not Modified',
            400 => 'Bad Request',
            401 => 'Unauthorized',
            403 => 'Forbidden',
            404 => 'Not Found',
            500 => 'Internal Server Error',
            503 => 'Service Unavailable',
        );

        if (!array_key_exists($code, $messages)) {
            throw new Exception('Response code not supported: ' . $code);
        }

        if (strpos(PHP_SAPI, '-fcgi') === false) {
            $key = 'HTTP/1.1';

            if (array_key_exists('SERVER_PROTOCOL', $_SERVER)
                && strlen($_SERVER['SERVER_PROTOCOL']) < 15
                && strlen($_SERVER['SERVER_PROTOCOL']) > 1) {
                $key = $_SERVER['SERVER_PROTOCOL'];
            }
        } else {
            // FastCGI
            $key = 'Status:';
        }

        $message = $messages[$code];
        Common::sendHeader($key . ' ' . $code . ' ' . $message);
    }
1020548
function responseCode($code = null) {
		if ($code === null) {
			return $this->http_response_code;
		}
		else { // $code !== null, act as setter
			$this->http_response_code = $code;
			return $this;
		}
	}
290924
public function assertResponseHeaderIs($header, $value) {
        $this->requireResponse();

        try {
            Assertion::same(
                $actual = $this->response->getHeaderLine($header),
                $value,
                sprintf(
                    'Expected the "%s" response header to be "%s", got "%s".',
                    $header,
                    $value,
                    $actual
                )
            );
        } catch (AssertionFailure $e) {
            throw new AssertionFailedException($e->getMessage());
        }
    }
593931
protected function _assertValidateStatus($code)
    {
        if (! is_numeric($code)
            || is_float($code)
            || $code < 100
            || $code >= 600
        )
            throw new \InvalidArgumentException(sprintf(
                'Invalid status code "%s"; must be an integer between 100 and 599, inclusive',
                (is_scalar($code) ? $code : gettype($code))
            ));
    }
616564
public function setHttpResponseCode($code)
        {
            if (!is_int($code) || (100 > $code) || (599 < $code)) {
                throw new Exception('Invalid HTTP response code');
            }

            if ((300 <= $code) && (307 >= $code)) {
                $this->_isRedirect = true;
            } else {
                $this->_isRedirect = false;
            }

            $this->_httpResponseCode = $code;

            return $this;
        }
708073
public static function errorToException($code){
    if(!isset(self::$codeMap[$code])){
      return new BadResponseException(sprintf(
        'Undefined error code "%s"',
        $code
      ));
    }
    $exceptionClass = self::$codeMap[$code];
    return  new $exceptionClass;
  }
375992
public function dispatchCode($code) {
		if($this->isActive()) {
			$previousLastError = error_get_last();
			$oldDisplayErrors = ini_set('display_errors', false);
			$result = $this->evalProvider->evaluate($code);
			ini_set('display_errors', $oldDisplayErrors);

			$message = new EvalResultMessage();
			$message->return = $this->dumper->dump($result->return);
			$message->output = $this->dumper->dump($result->output);
			$message->time = round($result->time, 6);

			$newLastError = error_get_last();
			if($newLastError && $newLastError != $previousLastError) {
				$this->connector->getErrorsDispatcher()->dispatchError($newLastError ['type'], $newLastError ['message'], $newLastError ['file'], $newLastError ['line'], 999);
			}
			if($result->exception) {
				$this->connector->getErrorsDispatcher()->dispatchException($result->exception);
			}
			$this->sendMessage($message);
		}
	}
322433
public function setCode( $code )
	{
		$this->_checkCode( $code );

		$this->_values['code'] = (string) $code;
		$this->setModified();
	}
1085862
public function assertResponseStatusLineIsNot($line) {
        $this->requireResponse();

        try {
            $actualStatusLine = sprintf(
                '%d %s',
                $this->response->getStatusCode(),
                $this->response->getReasonPhrase()
            );

            Assertion::notSame($line, $actualStatusLine, sprintf(
                'Did not expect response status line "%s".',
                $line
            ));
        } catch (AssertionFailure $e) {
            throw new AssertionFailedException($e->getMessage());
        }
    }
328308
public function setHttpStatusCode($code)
    {
        $code = intval($code);
        if (!is_int($code)
            || $code < 100
            || $code > 599
        ) {
            trigger_error('Invalid HTTP status code, not taken into account.', E_USER_WARNING);
            return false;
        }
        $this->httpStatusCode = $code;
        return true;
    }