Aerys\StandardResponse::stream PHP Method

stream() public method

If response output has not yet started headers will also be sent when this method is invoked.
public stream ( string $partialBody ) : Amp\Promise
$partialBody string
return Amp\Promise to be succeeded whenever local buffers aren't full
    public function stream(string $partialBody) : \Amp\Promise
    {
        if ($this->state & self::ENDED) {
            throw new \LogicException("Cannot stream: response already sent");
        }
        if (!($this->state & self::STARTED)) {
            $this->setCookies();
            // A * (as opposed to a numeric length) indicates "streaming entity content"
            $headers = $this->headers;
            $headers[":aerys-entity-length"] = "*";
            $this->codec->send($headers);
        }
        $this->codec->send($partialBody);
        // Don't update the state until *AFTER* the codec operation so that if
        // it throws we can handle InternalFilterException appropriately in the server.
        $this->state = self::STREAMING | self::STARTED;
        return $this->client->bufferPromisor ? $this->client->bufferPromisor->promise() : new \Amp\Success();
    }