You are here

private function MessageTrait::setHeaders in Auth0 Single Sign On 8.2

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 137

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_int($header)) {

      // Numeric array keys are converted to int by PHP but having a header name '123' is not forbidden by the spec
      // and also allowed in withHeader(). So we need to cast it to string again for the following assertion to pass.
      $header = (string) $header;
    }
    $this
      ->assertHeader($header);
    $value = $this
      ->normalizeHeaderValue($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;
    }
  }
}