public static function Serializer::toString in Zircon Profile 8
Same name in this branch
- 8 vendor/zendframework/zend-diactoros/src/Request/Serializer.php \Zend\Diactoros\Request\Serializer::toString()
- 8 vendor/zendframework/zend-diactoros/src/Response/Serializer.php \Zend\Diactoros\Response\Serializer::toString()
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-diactoros/src/Response/Serializer.php \Zend\Diactoros\Response\Serializer::toString()
Create a string representation of a response.
Parameters
ResponseInterface $response:
Return value
string
File
- vendor/
zendframework/ zend-diactoros/ src/ Response/ Serializer.php, line 66
Class
Namespace
Zend\Diactoros\ResponseCode
public static function toString(ResponseInterface $response) {
$reasonPhrase = $response
->getReasonPhrase();
$headers = self::serializeHeaders($response
->getHeaders());
$body = (string) $response
->getBody();
$format = 'HTTP/%s %d%s%s%s';
if (!empty($headers)) {
$headers = "\r\n" . $headers;
}
if (!empty($body)) {
$headers .= "\r\n\r\n";
}
return sprintf($format, $response
->getProtocolVersion(), $response
->getStatusCode(), $reasonPhrase ? ' ' . $reasonPhrase : '', $headers, $body);
}