You are here

public static function Serializer::fromStream in Zircon Profile 8

Same name in this branch
  1. 8 vendor/zendframework/zend-diactoros/src/Request/Serializer.php \Zend\Diactoros\Request\Serializer::fromStream()
  2. 8 vendor/zendframework/zend-diactoros/src/Response/Serializer.php \Zend\Diactoros\Response\Serializer::fromStream()
Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-diactoros/src/Response/Serializer.php \Zend\Diactoros\Response\Serializer::fromStream()

Parse a response from a stream.

Parameters

StreamInterface $stream:

Return value

ResponseInterface

Throws

InvalidArgumentException when the stream is not readable.

UnexpectedValueException when errors occur parsing the message.

1 call to Serializer::fromStream()
Serializer::fromString in vendor/zendframework/zend-diactoros/src/Response/Serializer.php
Deserialize a response string to a response instance.

File

vendor/zendframework/zend-diactoros/src/Response/Serializer.php, line 44

Class

Serializer

Namespace

Zend\Diactoros\Response

Code

public static function fromStream(StreamInterface $stream) {
  if (!$stream
    ->isReadable() || !$stream
    ->isSeekable()) {
    throw new InvalidArgumentException('Message stream must be both readable and seekable');
  }
  $stream
    ->rewind();
  list($version, $status, $reasonPhrase) = self::getStatusLine($stream);
  list($headers, $body) = self::splitStream($stream);
  return (new Response($body, $status, $headers))
    ->withProtocolVersion($version)
    ->withStatus($status, $reasonPhrase);
}