Sets a HeaderBag containing all headers;

@param string $headers

@return Response
@author Livingstone Fultang
10015
public function setHeaders(array $headers = [])
    {

        $this->headers = ($headers instanceof Headers) ? $headers : new Headers((array)$headers);

        return $this;

    }
80594
public static function validate(HeaderBag $headers)
    {
        $errors = [];

        foreach (self::$delegates as $delegate => $headerList)
        {
            $class = self::VALIDATOR_NAMESPACE.'\\'.$delegate;

            if ( ! is_array($headerList))
            {
                $headerList = [$headerList];
            }

            foreach ($headerList as $headerName)
            {
                $headers->forEachNamed(
                    $headerName,
                    function (Header $header) use (&$errors, $class)
                    {
                        $errors = array_merge(
                            $errors,
                            $class::validate($header)
                        );
                    }
                );
            }
        }

        return $errors;
    }
110987
public function appendHeaders(array $headers = [])
    {
        // Append headers.
        $this->headers = collect($this->headers)->merge($headers)->all();

        // Return calling object.
        return $this;
    }
1291631
protected function setHeaders(array $headers)
    {
        foreach ($headers as $header) {

            if (isset($header['name']) && isset($header['value'])) {
                $this->headers[$header['name']] = $header['value'];
            }
        }

        return $this;
    }
267261
public function addHeaders(array $headers)
    {
        $headerCollection = $this->getHeaders();
        foreach ($headers as $name => $value) {
            $headerCollection->add($name, $value);
        }
        return $this;
    }
546629
public function setHeaders(array $headers)
    {
        foreach ($this->headers as $name => $value) {
            $this->addHeader($name, $value);
        }
        return $this;
    }
1216085
public function header($headers) {
        // Record HTTP header
        if (is_array($headers)) {
            foreach ($headers as $header) {
                array_push($this->_headers, $header);
            }
        } else if (is_string($headers)) {
            array_push($this->_headers, $headers);
        }
        
        return $this;
    }
211295
private function validateHeaders(HeaderBag $headers)
    {
        $this->errors = array_merge(
            $this->errors,
            Validator::validate($headers)
        );
    }
1182217
public function setHeaders($headers)
    {
        if (!empty($this->headers)) {
            $this->headers = array_merge($this->headers, $headers);
        } else {
            $this->headers = $headers;
        }
        $this->headers = array_merge($this->headers, $headers);

        if ($this->client instanceof \swoole_http_client) {
            $this->client->setHeaders($this->headers);
        }
        return $this;
    }
232523
public function addDefaultHeaders($headers)
    {
        foreach ($headers as $name => $value) {
            $this->addDefaultHeader($name, $value);
        }

        return $this;
    }
357455
public function setHeaders(array $headers)
    {
        $this->headers = [];
        foreach ($headers as $name => $val) {
            $this->addHeader($name, $val);
        }
        return $this;
    }
386992
public function setBags(array $bags)
    {
        foreach ($bags as $name => $bag) {
            $this->setBag($name, $bag);
        }

        return $this;
    }
93240
public function setMany(array $headers)
    {
        $this->clear();

        foreach ($headers as $header) {
            $this->append($header);
        }

        return $this;
    }
890161
private function reportMissingHeaders(HeaderBag $headers)
    {
        foreach ($this->reportMissingHeaders as $header)
        {
            if (
                ! $headers->has($header)
                and empty($this->reportMissingExceptions[strtolower($header)])
            ) {
                $this->addError(
                    "Missing security header: '$header'",
                    E_USER_WARNING
                );
            }
        }
    }
846220
public function set(\BearFramework\App\Response\Header $header): self
    {
        $this->data[$header->name] = $header;
        return $this;
    }
1098718
private function setRequestHeaders($headers = array()) {
        foreach ($this->headers as $key => $value) {
            $headers[] = $key . ': ' . $value;
        }
        curl_setopt($this->request, CURLOPT_HTTPHEADER, $headers);
    }
350173
public function setHeaders(HeadersInterface &$headers)
    {
        foreach ($this->data as $name => $settings) {
            $this->setHeader($headers, $name, $settings);
        }
    }