lithium\action\Response::render()

public method

Render a response by writing headers and output. Output is echoed in chunks because of an issue where echo time increases exponentially on long message bodies.

Reponses which have a Location header set are indicating a redirect, will get their status code automatically adjusted to 302 (Found/Moved Temporarily) in case the status code before was 200 (OK). This is to allow easy redirects by setting just the Location header and is assumed to be the original intent of the user.

On responses with status codes 204 (No Content) and 302 (Found) a message body - even if one is set - will never be send. These status codes either don't have a message body as per their nature or they are ignored and can thus be omitted for performance reasons.

Returns

void

Source

	public function render() {
		$code = null;

		if (isset($this->headers['location']) || isset($this->headers['Location'])) {
			if ($this->status['code'] === 200) {
				$this->status(302);
			}
			$code = $this->status['code'];
		}
		if ($cookies = $this->_cookies()) {
			$this->headers('Set-Cookie', $cookies);
		}
		$this->_writeHeaders($this->status() ?: $this->status(500));
		$this->_writeHeaders($this->headers(), $code);

		if ($this->status['code'] === 302 || $this->status['code'] === 204) {
			return;
		}
		foreach ($this->body(null, $this->_config) as $chunk) {
			echo $chunk;
		}
	}