You are here

private function MessageTrait::setHeaders in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/guzzlehttp/psr7/src/MessageTrait.php \GuzzleHttp\Psr7\MessageTrait::setHeaders()
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 139

Class

MessageTrait
Trait implementing functionality common to requests and responses.

Namespace

GuzzleHttp\Psr7

Code

private function setHeaders(array $headers) {
  $this->headerLines = $this->headers = [];
  foreach ($headers as $header => $value) {
    $header = trim($header);
    $name = strtolower($header);
    if (!is_array($value)) {
      $value = trim($value);
      $this->headers[$name][] = $value;
      $this->headerLines[$header][] = $value;
    }
    else {
      foreach ($value as $v) {
        $v = trim($v);
        $this->headers[$name][] = $v;
        $this->headerLines[$header][] = $v;
      }
    }
  }
}