function HeaderBag::__toString
Returns the headers as a string.
File
-
vendor/
symfony/ http-foundation/ HeaderBag.php, line 42
Class
- HeaderBag
- HeaderBag is a container for HTTP headers.
Namespace
Symfony\Component\HttpFoundationCode
public function __toString() : string {
if (!($headers = $this->all())) {
return '';
}
ksort($headers);
$max = max(array_map('strlen', array_keys($headers))) + 1;
$content = '';
foreach ($headers as $name => $values) {
$name = ucwords($name, '-');
foreach ($values as $value) {
$content .= \sprintf("%-{$max}s %s\r\n", $name . ':', $value);
}
}
return $content;
}