public function HeaderBag::__toString

Returns the headers as a string.

Return value

string The headers

1 call to HeaderBag::__toString()
ResponseHeaderBag::__toString in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
Returns the headers as a string.
1 method overrides HeaderBag::__toString()
ResponseHeaderBag::__toString in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
Returns the headers as a string.

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/HeaderBag.php, line 47

Class

HeaderBag
HeaderBag is a container for HTTP headers.

Namespace

Symfony\Component\HttpFoundation

Code

public function __toString() {
  if (!$this->headers) {
    return '';
  }
  $max = max(array_map('strlen', array_keys($this->headers))) + 1;
  $content = '';
  ksort($this->headers);
  foreach ($this->headers as $name => $values) {
    $name = implode('-', array_map('ucfirst', explode('-', $name)));
    foreach ($values as $value) {
      $content .= sprintf("%-{$max}s %s\r\n", $name . ':', $value);
    }
  }
  return $content;
}