You are here

public function HttpHeaderBag::append in RESTful 7.2

Appends the values of the passed in header to if the header already exists.

Parameters

HttpHeaderInterface $header: The header object or an associative array with the name and value.

Throws

ServerConfigurationException

Overrides HttpHeaderBagInterface::append

File

src/Http/HttpHeaderBag.php, line 89
Contains \Drupal\restful\Http\HttpHeaderBag.

Class

HttpHeaderBag

Namespace

Drupal\restful\Http

Code

public function append(HttpHeaderInterface $header) {
  if (!$this
    ->has($header
    ->getId())) {
    $this
      ->add($header);
    return;
  }
  $existing_header = $this
    ->get($header
    ->getId());

  // Append all the values in the passed in header to the existing header
  // values.
  foreach ($header
    ->get() as $value) {
    $existing_header
      ->append($value);
  }
}