@param array $headers

@return string
181322
protected function findHeader(array $headers): string
    {
        $signature = '';
        foreach ($headers as $header) {
            if ($this->request->hasHeader($header)) {
                $value = $this->request->getHeader($header);
                $value = array_shift($value);
                if ($value !== null) {
                    $signature = $value;
                    continue;
                }
            }
        }

        return $signature;
    }
1356649
protected function transformHeadersToServerVars(array $headers): array
    {
        $server = [];
        $prefix = 'HTTP_';

        foreach ($headers as $name => $value) {
            $name = str_replace(strtoupper($name), '-', '_');

            if ($name !== 'CONTENT_TYPE' && ! starts_with($name, $prefix)) {
                $name = $prefix.$name;
            }

            $server[$name] = $value;
        }

        return $server;
    }
133994
private function tokensToString(array $tokens): string
    {
        $lineCount = 0;
        $headerLines = [];
        $headerLines[] = $this->name.': ';
        $currentLine = &$headerLines[$lineCount++];

        // Build all tokens back into compliant header
        foreach ($tokens as $i => $token) {
            // Line longer than specified maximum or token was just a new line
            if (("\r\n" === $token) ||
                ($i > 0 && \strlen($currentLine.$token) > $this->lineLength)
                && 0 < \strlen($currentLine)) {
                $headerLines[] = '';
                $currentLine = &$headerLines[$lineCount++];
            }

            // Append token to the line
            if ("\r\n" !== $token) {
                $currentLine .= $token;
            }
        }

        // Implode with FWS (RFC 2822, 2.2.3)
        return implode("\r\n", $headerLines);
    }
1182849
protected function mapHeaders(array $headers)
    {
        $mappedHeaders = array();
        foreach ($headers as $headerPair) {
            list($name, $value) = $headerPair;
            $mappedHeaders[strtolower($name)] = $value;
        }

        return $mappedHeaders;
    }
376545
public function setHeaders(array $headers)
    {
        foreach ($headers as $key => $value) {
            $this->headers[$key] = $value;
        }

        return $this;
    }
229644
protected function encodeHeaders($headers = [])
    {
        $data = '';

        foreach ($headers as $name=>$values)
        {
            $temp = [];
            $data .= $name . ": ";
            $values = (array) $values;

            foreach ($values as $value)
            {
                $temp[] = $this->encodeHeader($value);
            }

            $data .= implode(", ", $temp);
            $data .= "\r\n";
        }

        return $data;
    }
258920
protected function transformHeadersToServerVars(array $headers)
    {
        $server = [];
        $prefix = 'HTTP_';

        foreach ($headers as $name => $value) {
            $name = strtr(strtoupper($name), '-', '_');

            if (! Str::startsWith($name, $prefix) && $name != 'CONTENT_TYPE') {
                $name = $prefix.$name;
            }

            $server[$name] = $value;
        }

        return $server;
    }
659508
public function encode(array $headers): string {
        // @TODO implementation is deliberately primitive... [doesn't use any dynamic table...]
        $output = "";

        foreach ($headers as $name => $values) {
            foreach ((array) $values as $value) {
                if (isset(self::$indexMap[$name])) {
                    $index = self::$indexMap[$name];
                    if ($index < 0x10) {
                        $output .= \chr($index);
                    } else {
                        $output .= "\x0f" . \chr($index - 0x0f);
                    }
                } elseif (\strlen($name) < 0x7f) {
                    $output .= "\0" . \chr(\strlen($name)) . $name;
                } else {
                    $output .= "\0\x7f" . self::encodeDynamicInteger(\strlen($name) - 0x7f) . $name;
                }

                if (\strlen($value) < 0x7f) {
                    $output .= \chr(\strlen($value)) . $value;
                } else {
                    $output .= "\x7f" . self::encodeDynamicInteger(\strlen($value) - 0x7f) . $value;
                }
            }
        }

        return $output;
    }
353982
public function header(array $headers) {

        $formattedHeaders = [];

        $combinedHeaders = array_change_key_case(array_merge($this->header, $headers));

        foreach ($combinedHeaders as $key => $val)

            $formattedHeaders[] = trim(strtolower($key)) . ':' . $val;

        $this->header = $formattedHeaders;

        return $this;

    }
576278
public static function capture(array $headers = null)
    {
        $headers  = $headers ?? apache_request_headers();
        $captured = [];
        foreach ($headers as $name => $value) {
            $captured[strtolower($name)] = new Header($name, $value);
        }

        return $captured;
    }
899801
public static function toArray($headers)
    {
        $headers .= "\r\n\r\n";
        preg_match_all('#[\r\n]*([\w-]+\:)(.+?)(?=([\r\n]+[\w-]+\:|[\r\n]{3,}|\n{2,}))#si', $headers, $result);

        $headers = [];
        foreach ($result[1] as $k => $header) {
            $header = strtolower(rtrim($header, ':'));
            $headers[$header][] = trim($result[2][$k]);
        }

        return $headers;
    }
739910
protected function fixHeaders(array $headers)
    {
        $fixedHeaders = array();

        foreach ($headers as $key => $value) {
            if (is_int($key)) {
                $fixedHeaders[] = $value;
            } else {
                $fixedHeaders[] = sprintf('%s:%s', $key, $value);
            }
        }

        return $fixedHeaders;
    }
340016
protected function getHeader(array $params)
	{
		// Prepare the function's header
		$header = "/**\n";
		foreach ($params as $paramName => $paramType)
		{
			$header .= '* @param {' . $paramType . '} ' . $paramName . "\n";
		}
		$header .= "*/\n";

		return $header;
	}
809737
protected function findContentTypeInHeaders($headers)
    {

        foreach ($headers as $header) {

            $lower = trim(strtolower($header));

            if (strpos($lower, 'content-type:') !== 0) {
                continue;
            }

            $parts = explode(';', $header);

            $keyAndValue = explode(': ', trim($parts[0]), 2);

            if (!isset($keyAndValue[1])) {
                continue;
            }

            return trim($keyAndValue[1]);

        }

        return '';
    }
665538
private function parseHeaders($headers)
    {
        $result = [];

        foreach (preg_split("/\\r\\n|\\r|\\n/", $headers) as $row) {
            $header = explode(':', $row, 2);

            if (count($header) == 2) {
                $result[$header[0]] = trim($header[1]);
            }
            else {
                $result[] = $header[0];
            }
        }

        return $result;
    }
1116612
private function buildCanonicalHeaders($headers)
    {
        $sortMap = [];
        foreach ($headers as $headerKey => $headerValue) {
            $key = strtolower($headerKey);
            if (strpos($key, "x-acs-") === 0) {
                $sortMap[$key] = $headerValue;
            }
        }
        ksort($sortMap);
        $headerString = "";
        foreach ($sortMap as $sortMapKey => $sortMapValue) {
            $headerString = $headerString . $sortMapKey . ":" . $sortMapValue . self::$headerSeparator;
        }
        return $headerString;
    }
352972
protected function incrementHeaders(array $headers)
    {
        $incrementedHeaders = [];
        foreach (array_count_values($headers) as $header => $count) {
            if ($count > 1) {
                $incrementedHeaders[] = $header;
                for ($i = 1; $i < $count; $i++) {
                    $incrementedHeaders[] = $header . $i;
                }
            } else {
                $incrementedHeaders[] = $header;
            }
        }

        return $incrementedHeaders;
    }