Collect all headers and parse into consistent string

@return  array
978965
public function get_headers()
	{
		$headers = array();
		foreach ($this->headers as $key => $value)
		{
			$headers[] = is_int($key) ? $value : $key.': '.$value;
		}

		return $headers;
	}
625067
public function getHeaders()
    {
        $headers = array();
        foreach ($this->response->getHeaders()->getAll() as $header => $headerObject) {
            $allHeaderValues = $headerObject->toArray();
            $headers[strtolower($header)] = implode(';', $allHeaderValues);
        }

        return $headers;
    }
928588
public function extractHeaders()
    {
        $headers = [];
        foreach (array_keys($this->cors) as $headerField) {
            $headerData = $this->request->getHeaderLine($headerField);
            if ($headerData !== null) {
                $headers[$headerField] = $headerData;
            }
        }

        return $headers;
    }
1178874
protected function getAllHeaders()
    {
        $headers = [];

        foreach ($_SERVER as $key => $value) {
            if (substr($key, 0, 5) == 'HTTP_') {
                $key = substr($key, 5);
                $key = str_replace('_', ' ', strtolower($key));
                $key = str_replace(' ', '-', ucwords($key));

                $headers[$key] = $value;
            }
        }

        return $headers;
    }
6810
public function headers()
    {
        if (function_exists('getallheaders')) {
            $headers = getallheaders();
            return empty($headers) ? array() : $headers;
        }

        $headers = array();

        foreach ($_SERVER as $name => $value) {
            if (substr($name, 0, 5) == 'HTTP_') {
                $key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
                $headers[$key] = $value;
            }
        }

        return $headers;
    }
451356
public function parseHeaders(array $headers)
    {
        $parsed = [];

        foreach ($headers as $key => $val)
        {
            $parsed[] = $key . ': ' . $val;
        }

        return $parsed;
    }
321328
public function getHeaders()
    {
        $return = array();

        foreach ($this->contents as $key => $value) {
            if (strpos($key, self::$HttpPrefix) === 0) { // @codeCoverageIgnore
                $return[substr($key, strlen(self::$HttpPrefix))] = $value; // @codeCoverageIgnore
            } // @codeCoverageIgnore

            if (in_array($key, self::$HttpCustomHeaders)) {
                $return[$key] = $value;
            }
        }

        return $return;
    }
157026
public static function parseHeaders(string $headers): array
    {
        $res = [];

        foreach (explode("\r\n", $headers) as $line) {
            $line = trim($line);
            if (!$line) {
                continue;
            }

            $line = explode(': ', $line);
            if (count($line) !== 2) {
                continue;
            }

            $res[strtolower($line[0])] = $line[1];
        }

        return $res;
    }
810802
protected function determineHeaders()
    {
        $params = $this->getServerParams();
        $headers = [];
        
        foreach ($params as $key => $value) {
            $name = $this->serverParamKeyToHeaderName($key);
            
            if (isset($name) && is_string($value)) {
                $headers[$name] = [$value];
            }
        }
        
        return $headers;
    }
1144888
public static function parseHeaders(array $headers)
    {
        $headerGroups = array();
        $headerList = array();

        // Collect matching headers into groups
        foreach ($headers as $line) {
            list($key, $value) = explode(': ', $line, 2);
            if (!isset($headerGroups[$key])) {
                $headerGroups[$key] = array();
            }
            $headerGroups[$key][] = $value;
        }
        
        // Collapse groups
        foreach ($headerGroups as $key => $values) {
            $headerList[$key] = implode(', ', $values);
        }

        return $headerList;
    }
1179736
public function composeHeaderLines()
    {
        if (!$this->hasHeaders()) {
            return [];
        }
        $headers = [];
        foreach ($this->getHeaders() as $name => $values) {
            $name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $name)));
            foreach ($values as $value) {
                $headers[] = "$name: $value";
            }
        }
        return $headers;
    }
256582
public function getHeaders(): array
    {
        if ($this->headers === null && $this->headersText !== null) {
            $this->headers = [];

            foreach (explode("\n", $this->headersText) as $line) {
                $pos = strpos($line, ':');

                if ($pos === false) {
                    // this is one-line header
                    $this->headers[$line] = null;
                } else {
                    $name = substr($line, 0, $pos);
                    $value = substr($line, $pos + 1);
                    $this->headers[$name] = trim($value);
                }
            }
        }

        return $this->headers ?? [];
    }
776823
public function getHeadersAsArray()
    {
        $headers = array();
        foreach ($this->getHeaders() as $headerNode) {
            $header = array(
                'type' => $headerNode->getType(),
                'name' => $headerNode->getName(),
                'value' => $headerNode->getValue(),
                'uri' => $headerNode->getUri(),
                'override' => $headerNode->getOverride(),
                'append' => $headerNode->getAppend()
            );
            $headers[$headerNode->getType()][] = $header;
        }
        return $headers;
    }
628944
public function getRequestHeaders(): array
    {
        $headers = clone $this->headers();

        if (!$headers->headerExists('Content-type')) {
            if ($contentType = $this->getContentType()) {
                if (($charset = $this->getCharset()) && (stripos($contentType, 'charset=') === false)) {
                    $contentType .= "; charset={$charset}";
                }

                $headers->setHeader('Content-type', $contentType);
            }
        }

        return $headers->getHeadersForRequest();
    }
448481
public function getResponseHeaders() {
    $headerStrings = headers_list();
    header_remove();
    $headers = [];
    foreach ($headerStrings as $header) {
      list($name, $value) = explode(':', $header, 2);
      $headers[trim($name)] = trim($value);
    }
    return $headers;
  }
1024808
public static function getAllRequestHeaders() {
        static $_cached_headers = false;
        if($_cached_headers!==false) {
            return $_cached_headers;
        }
        $headers = array();
        if(function_exists('getallheaders')) {
            foreach( getallheaders() as $name => $value ) {
                $headers[strtolower($name)] = $value;
            }
        } else {
            foreach($_SERVER as $name => $value) {
                if(substr($name, 0, 5) == 'HTTP_') {
                    $headers[strtolower(str_replace(' ', '-', str_replace('_', ' ', substr($name, 5))))] = $value;
                }
            }
        }
        return $_cached_headers = $headers;
    }
265296
protected function readHeaders()
    {
        $ret = [];
        foreach ($this->environment as $key => $value) {
            # Note: the content-type and content-length headers always come
            # after the `CONTENT_TYPE` and `CONTENT_LENGTH` values in the
            # $_SERVER superglobal; if you use the values for the non `HTTP_...`
            # version, they will just be overwritten by the `HTTP_` version.
            if (strpos($key, "HTTP_") === 0) {
                $key = substr($key, 5);
                $key = strtolower($key);
                $key = str_replace("_", "-", $key);
                $ret[$key] = $value;
            }
        }
        return $ret;
    }