Zend\Diactoros\AbstractSerializer::splitStream PHP Метод

splitStream() защищенный статический Метод

Returns an array containing two elements - The first is an array of headers - The second is a StreamInterface containing the body content
protected static splitStream ( Psr\Http\Message\StreamInterface $stream ) : array
$stream Psr\Http\Message\StreamInterface
Результат array
    protected static function splitStream(StreamInterface $stream)
    {
        $headers = [];
        $currentHeader = false;
        while ($line = self::getLine($stream)) {
            if (preg_match(';^(?P<name>[!#$%&\'*+.^_`\\|~0-9a-zA-Z-]+):(?P<value>.*)$;', $line, $matches)) {
                $currentHeader = $matches['name'];
                if (!isset($headers[$currentHeader])) {
                    $headers[$currentHeader] = [];
                }
                $headers[$currentHeader][] = ltrim($matches['value']);
                continue;
            }
            if (!$currentHeader) {
                throw new UnexpectedValueException('Invalid header detected');
            }
            if (!preg_match('#^[ \\t]#', $line)) {
                throw new UnexpectedValueException('Invalid header continuation');
            }
            // Append continuation to last header value found
            $value = array_pop($headers[$currentHeader]);
            $headers[$currentHeader][] = $value . ltrim($line);
        }
        // use RelativeStream to avoid copying initial stream into memory
        return [$headers, new RelativeStream($stream, $stream->tell())];
    }