You are here

private function MessageTrait::setHeaders in Lockr 7.3

2 calls to MessageTrait::setHeaders()
Request::__construct in vendor/guzzlehttp/psr7/src/Request.php
Response::__construct in vendor/guzzlehttp/psr7/src/Response.php

File

vendor/guzzlehttp/psr7/src/MessageTrait.php, line 143

Class

MessageTrait
Trait implementing functionality common to requests and responses.

Namespace

GuzzleHttp\Psr7

Code

private function setHeaders(array $headers) {
  $this->headerNames = $this->headers = [];
  foreach ($headers as $header => $value) {
    if (!is_array($value)) {
      $value = [
        $value,
      ];
    }
    $value = $this
      ->trimHeaderValues($value);
    $normalized = strtolower($header);
    if (isset($this->headerNames[$normalized])) {
      $header = $this->headerNames[$normalized];
      $this->headers[$header] = array_merge($this->headers[$header], $value);
    }
    else {
      $this->headerNames[$normalized] = $header;
      $this->headers[$header] = $value;
    }
  }
}