You are here

protected static function AbstractSerializer::serializeHeaders in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-diactoros/src/AbstractSerializer.php \Zend\Diactoros\AbstractSerializer::serializeHeaders()

Serialize headers to string values.

Parameters

array $headers:

Return value

string

2 calls to AbstractSerializer::serializeHeaders()
Serializer::toString in vendor/zendframework/zend-diactoros/src/Request/Serializer.php
Serialize a request message to a string.
Serializer::toString in vendor/zendframework/zend-diactoros/src/Response/Serializer.php
Create a string representation of a response.

File

vendor/zendframework/zend-diactoros/src/AbstractSerializer.php, line 127

Class

AbstractSerializer
Provides base functionality for request and response de/serialization strategies, including functionality for retrieving a line at a time from the message, splitting headers from the body, and serializing headers.

Namespace

Zend\Diactoros

Code

protected static function serializeHeaders(array $headers) {
  $lines = [];
  foreach ($headers as $header => $values) {
    $normalized = self::filterHeader($header);
    foreach ($values as $value) {
      $lines[] = sprintf('%s: %s', $normalized, $value);
    }
  }
  return implode("\r\n", $lines);
}