Set status code

@param int $code
@param string $reasonPhrase

@return Response
339156
public function withStatus($code, $reasonPhrase = '')
    {
        $this->statusCode = (int)$code;
        if ($reasonPhrase == '') {
            $this->reasonPhrase = Status::getReasonPhrase($this->statusCode);
        } else {
            $this->reasonPhrase = $reasonPhrase;
        }

        return $this;
    }
352666
public function setStatusCode($code)
    {
        if (!is_int($code) || ($code < 100) || ($code > 599)) {
            throw new \BedRest\Rest\Exception("Invalid HTTP response code.");
        }

        $this->statusCode = $code;
    }
494574
@Override
    public void setStatusCode(StatusCodes code) {

        if (!code.equals(this.myStatusCode)) {
            this.myStatusCode = code;
            // no matter what, empty out the reason phrase information so that it
            // will default to match this new status code
            this.myReason = null;
            this.myReasonBytes = null;
            super.setFirstLineChanged();
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
            Tr.event(tc, "setStatusCode(sc): " + code);
        }
    }
700838
public static function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
    {
        return self::getResponseFactory()->createResponse($code, $reasonPhrase);
    }
844068
private function setStatusHeader($code = 200)
    {
        if (empty(self::$codes[$code])) {
            $code = 200;
        }

        if (!empty($this->response)) {
            $this->response->status($code);
        }

        return $this;
    }
1305403
public function setStatusCode($code)
    {
        // set status code
        $this->statusCode = $code;

        // lookup reason phrase by code and set
        $this->setStatusReasonPhrase(HttpProtocol::getStatusReasonPhraseByCode($code));
    }
8847
public function setStatusCode($code = null)
    {
        if (!empty($code)) {
            $this->_statusCode = $code;
            http_response_code($this->_statusCode); // this sends the http status code
        }
    }
1225894
public static function setStatus($code) {

		if(false === ('-' . intval($code) == '-' . $code)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($code)), E_USER_ERROR);
		}

		$protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';

		switch($code) {

			case 100 : header($protocol . ' 100 Continue'); break;
			case 101 : header($protocol . ' 101 Switching Protocols'); break;
			case 102 : header($protocol . ' 102 Processing'); break;
			case 200 : header($protocol . ' 200 OK'); break;
			case 201 : header($protocol . ' 201 Created'); break;
			case 202 : header($protocol . ' 202 Accepted'); break;
			case 203 : header($protocol . ' 203 Non-Authoritative Information'); break;
			case 204 : header($protocol . ' 204 No Content'); break;
			case 205 : header($protocol . ' 205 Reset Content'); break;
			case 206 : header($protocol . ' 206 Partial Content'); break;
			case 207 : header($protocol . ' 207 Multi-Status'); break;
			case 208 : header($protocol . ' 208 Already Reported'); break;
			case 226 : header($protocol . ' 226 IM Used'); break;
			case 300 : header($protocol . ' 300 Multiple Choices'); break;
			case 301 : header($protocol . ' 301 Moved Permanently'); break;
			case 302 : header($protocol . ' 302 Found'); break;
			case 303 : header($protocol . ' 303 See Other'); break;
			case 304 : header($protocol . ' 304 Not Modified'); break;
			case 305 : header($protocol . ' 305 Use Proxy'); break;
			case 306 : header($protocol . ' 306 Switch Proxy'); break;
			case 307 : header($protocol . ' 307 Temporary Redirect'); break;
			case 308 : header($protocol . ' 308 Permanent Redirect'); break;
			case 400 : header($protocol . ' 400 Bad Request'); break;
			case 401 : header($protocol . ' 401 Unauthorized'); break;
			case 402 : header($protocol . ' 402 Payment Required'); break;
			case 403 : header($protocol . ' 403 Forbidden'); break;
			case 404 : header($protocol . ' 404 Not Found'); break;
			case 405 : header($protocol . ' 405 Method Not Allowed'); break;
			case 406 : header($protocol . ' 406 Not Acceptable'); break;
			case 407 : header($protocol . ' 407 Proxy Authentication Required'); break;
			case 408 : header($protocol . ' 408 Request Timeout'); break;
			case 409 : header($protocol . ' 409 Conflict'); break;
			case 410 : header($protocol . ' 410 Gone'); break;
			case 411 : header($protocol . ' 411 Length Required'); break;
			case 412 : header($protocol . ' 412 Precondition Failed'); break;
			case 413 : header($protocol . ' 413 Payload Too Large'); break;
			case 414 : header($protocol . ' 414 Request-URI Too Long'); break;
			case 415 : header($protocol . ' 415 Unsupported Media Type'); break;
			case 416 : header($protocol . ' 416 Requested Range Not Satisfiable'); break;
			case 417 : header($protocol . ' 417 Expectation Failed'); break;
			case 418 : header($protocol . ' 418 I\'m a teapot'); break;
			case 419 : header($protocol . ' 419 Authentication Timeout'); break;
			case 420 : header($protocol . ' 420 Method Failure'); break;
			case 421 : header($protocol . ' 421 Misdirected Request'); break;
			case 422 : header($protocol . ' 422 Unprocessable Entity'); break;
			case 423 : header($protocol . ' 423 Locked'); break;
			case 424 : header($protocol . ' 424 Failed Dependency'); break;
			case 426 : header($protocol . ' 426 Upgrade Required'); break;
			case 428 : header($protocol . ' 428 Precondition Required'); break;
			case 429 : header($protocol . ' 429 Too Many Requests'); break;
			case 431 : header($protocol . ' 431 Request Header Fields Too Large'); break;
			case 440 : header($protocol . ' 440 Login Timeout '); break;
			case 444 : header($protocol . ' 444 No Response'); break;
			case 449 : header($protocol . ' 449 Retry With'); break;
			case 450 : header($protocol . ' 450 Blocked by Windows Parental Controls'); break;
			case 451 : header($protocol . ' 451 Unavailable For Legal Reasons'); break;
			case 494 : header($protocol . ' 494 Request Header Too Large'); break;
			case 495 : header($protocol . ' 495 Cert Error'); break;
			case 496 : header($protocol . ' 496 No Cert'); break;
			case 497 : header($protocol . ' 497 HTTP to HTTPS'); break;
			case 498 : header($protocol . ' 498 Token expired/invalid'); break;
			case 499 : header($protocol . ' 499 Client Closed Request'); break;
			case 500 : header($protocol . ' 500 Internal Server Error'); break;
			case 501 : header($protocol . ' 501 Not Implemented'); break;
			case 502 : header($protocol . ' 502 Bad Gateway'); break;
			case 503 : header($protocol . ' 503 Service Unavailable'); break;
			case 504 : header($protocol . ' 504 Gateway Timeout'); break;
			case 505 : header($protocol . ' 505 HTTP Version Not Supported'); break;
			case 506 : header($protocol . ' 506 Variant Also Negotiates'); break;
			case 507 : header($protocol . ' 507 Insufficient Storage'); break;
			case 508 : header($protocol . ' 508 Loop Detected'); break;
			case 509 : header($protocol . ' 509 Bandwidth Limit Exceeded'); break;
			case 510 : header($protocol . ' 510 Not Extended'); break;
			case 511 : header($protocol . ' 511 Network Authentication Required'); break;
			case 520 : header($protocol . ' 520 Unknown Error'); break;
			case 522 : header($protocol . ' 522 Origin Connection Time-out'); break;
			case 598 : header($protocol . ' 598 Network read timeout error'); break;
			case 599 : header($protocol . ' 599 Network connect timeout error'); break;
		}
	}
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;
    }
324234
public final function setStatusCode($code)
    {
        if (! is_numeric($code)) {

            throw new ehough_shortstop_api_exception_InvalidArgumentException(
                'Status code must be an integer (' . $code . ')'
            );
        }

        $code = intval($code);

        if ($code < 100 || $code > 599) {

            throw new ehough_shortstop_api_exception_InvalidArgumentException(
                'Status code must be in the range of 100 - 599'
            );
        }

        $this->_statusCode = $code;
    }
1091019
public function setStatusCode(int $statusCode, string $statusText = null)
    {
        $this->statusCode = $statusCode;

        if ($statusText === null && isset(ResponseHeaders::$statusTexts[$statusCode])) {
            $this->statusText = ResponseHeaders::$statusTexts[$statusCode];
        } else {
            $this->statusText = $statusText;
        }
    }
951300
public function setStatus($code = 200, $text = '')
    {
        if (empty($code) or !is_numeric($code)) {
            throw new ResponseException('Status codes must be numeric.');
        }

        if (empty($text)) {
            if (!is_int($code)) {
                $code = (int) $code;
            }

            if (isset($this->httpCode[$code])) {
                $text = $this->httpCode[$code];
            } else {
                throw new ResponseException('No status text available. Please check your status code number or supply your own message text.');
            }
        }

        if (strpos(PHP_SAPI, 'cgi') === 0) {
            header('Status: ' . $code . ' ' . $text, true);
        } else {
            $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
            header($protocol . ' ' . $code . ' ' . $text, true, $code);
        }
    }
182073
public SipServletResponse createResponse(final int statusCode, final String reasonPhrase) {
		return createResponse(statusCode, reasonPhrase, true, false);
	}
329629
public function setStatusCode(int $code, string $message = null)
    {
        $this->code = $code;
        $this->message = $message;

        return $this;
    }
120045
protected function sendHttpVersionHeader(string $protocolVersion, int $statusCode,
        ?string $reasonPhrase = null):void
    {
        header(
            sprintf("HTTP/%s %d %s",
                $protocolVersion,
                $statusCode,
                $reasonPhrase ?? HttpReasonPhraseLookup::getReasonPhrase($statusCode)),
            true
        );
    }
932644
public function status( $code = null ) 
	{
		if ( !is_null( $code ) ) 
		{
			if ( headers_sent() && !CLI ) 
			{
				throw new CCException( "CCResponse::status - cannot change status header has already been send." );
			}

			$this->_status = $code; return $this;
		}

		return $this->_status;
	}
1335684
function status($code) {
		$reason=@constant('self::HTTP_'.$code);
		if (PHP_SAPI!='cli')
			header($_SERVER['SERVER_PROTOCOL'].' '.$code.' '.$reason);
		return $reason;
	}