Aerys\StandardResponse::end PHP Method

end() public method

User applications are NOT required to call Response::end() as the server will handle this automatically as needed. Passing the optional $finalBody is equivalent to the following: $response->stream($finalBody); $response->end();
public end ( string $finalBody = null )
$finalBody string Optional final body data to send
    public function end(string $finalBody = null)
    {
        if ($this->state & self::ENDED) {
            if (isset($finalBody)) {
                throw new \LogicException("Cannot send body data: response output already ended");
            }
            return;
        }
        if (!($this->state & self::STARTED)) {
            $this->setCookies();
            // An @ (as opposed to a numeric length) indicates "no entity content"
            $entityValue = isset($finalBody) ? \strlen($finalBody) : "@";
            $headers = $this->headers;
            $headers[":aerys-entity-length"] = $entityValue;
            $this->codec->send($headers);
        }
        if (isset($finalBody)) {
            $this->codec->send($finalBody);
        }
        $this->codec->send(null);
        // Update the state *AFTER* the codec operation so that if it throws
        // we can handle things appropriately in the server.
        $this->state = self::ENDED | self::STARTED;
    }