lithium\net\http\Response::status()

public method

Set and get the status for the response.

Parameters

  • string $key

    Optional. Set to 'code' or 'message' to return just the code or message of the status, otherwise returns the full status header.

  • string $status

    The code or message of the status you wish to set.

Returns

string

Returns the full HTTP status, with version, code and message or dending on $key just the code or message.

Source

	public function status($key = null, $status = null) {
		if ($status === null) {
			$status = $key;
		}
		if ($status) {
			$this->status = array('code' => null, 'message' => null);

			if (is_array($status)) {
				$key = null;
				$this->status = $status + $this->status;
			} elseif (is_numeric($status) && isset($this->_statuses[$status])) {
				$this->status = array('code' => $status, 'message' => $this->_statuses[$status]);
			} else {
				$statuses = array_flip($this->_statuses);

				if (isset($statuses[$status])) {
					$this->status = array('code' => $statuses[$status], 'message' => $status);
				}
			}
		}
		if (!isset($this->_statuses[$this->status['code']])) {
			return false;
		}
		if (isset($this->status[$key])) {
			return $this->status[$key];
		}
		return "{$this->protocol} {$this->status['code']} {$this->status['message']}";
	}