Returns all the HTTP headers as an array.

Every header is returned as an array, with one or more values.
760430
public function getHeaders(): array
    {
        $result = [];
        foreach ($this->headers as $headerInfo) {
            $result[$headerInfo[0]] = $headerInfo[1];
        }

        return $result;
    }
1333375
public function getHeaders()
    {
        if (!is_object($this->_headers)) {
            $headerCollection = new HeaderCollection();
            if (is_array($this->_headers)) {
                foreach ($this->_headers as $name => $value) {
                    if (is_int($name)) {
                        // parse raw header :
                        $rawHeader = $value;
                        if (strpos($rawHeader, 'HTTP/') === 0) {
                            $parts = explode(' ', $rawHeader, 3);
                            $headerCollection->add('http-code', $parts[1]);
                        } elseif (($separatorPos = strpos($rawHeader, ':')) !== false) {
                            $name = strtolower(trim(substr($rawHeader, 0, $separatorPos)));
                            $value = trim(substr($rawHeader, $separatorPos + 1));
                            $headerCollection->add($name, $value);
                        } else {
                            $headerCollection->add('raw', $rawHeader);
                        }
                    } else {
                        $headerCollection->set($name, $value);
                    }
                }
            }
            $this->_headers = $headerCollection;
        }
        return $this->_headers;
    }
370718
public static function getRequestHeaders()
    {
        if (function_exists('getallheaders')) {
            $headers = array();
            foreach (getallheaders() as $name => $value) {
                $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('-', ' ', $name))))] = $value;
            }
            return $headers;
        }
        $headers = array();
        foreach ($_SERVER as $name => $value) {
            if (substr($name, 0, 5) == 'HTTP_') {
                $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $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;
    }
1152653
private function parseHttpHeaders($headers) {
    $result = [];
    foreach ($headers as $header) {
      $values = explode(':', $header, 2);
      if (count($values) === 2) {
        list($key, $value) = $values;
        $key = trim($key);
        $value = trim($value);
        // Checking with real cURL it only sends a header if the key & the value
        // are set.
        if ($key && $value) {
          $result[$key] = $value;
        }
      }
    }
    return $result;
  }
256416
public function getHttpHeaders() {
        $headers = [];
        switch ($this->httpStatusCode) {
            case 401:
                $headers[] = 'HTTP/1.1 401 Unauthorized';
                break;
            case 403:
                $headers[] = 'HTTP/1.1 403 Forbidden';
                break;
            case 500:
                $headers[] = 'HTTP/1.1 500 Internal Server Error';
                break;
            case 501:
                $headers[] = 'HTTP/1.1 501 Not Implemented';
                break;
            case 400:
            default:
                $headers[] = 'HTTP/1.1 400 Bad Request';
                break;
        }

        return $headers;
    }
302527
public function asArray()
    {
        $headers = [];
        foreach (array_filter($this->storage) as $header => $value) {
            $headers[] = $header . ': ' . $value;
        }

        return $headers;
    }
1275528
public static function headers()
	{
		// disabled ?
		//
		if (!self::_debug())
		{
			return false;
		}

		if (!function_exists('getallheaders'))
		{
			function getallheaders()
			{
				$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;
			}
		}

		// render it
		//
		?>
<div class="krumo-title">
This is a list of all HTTP request headers.
</div>
		<?php
		return self::dump(getallheaders());
	}
1149327
public function toFlatArray() {
        $array = [];

        foreach ($this->headers as $key => $headers) {
            foreach ($headers as $header) {
                $array[] = $this->formatHeader($key, $header);
            }
        }

        return $array;
    }
329735
private static function getHeadersFromInput ()
	{
		// getallheaders available, use that
		if (function_exists('getallheaders')) return getallheaders();

		// getallheaders not available: manually extract 'm
		$headers = [];
		foreach ($_SERVER as $name => $value)
		{
			if (substr($name, 0, 5) == 'HTTP_') {
			    $key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
				$headers[$key] = $value;
			} else if (strtolower (substr ($name, 0, 7)) == 'content') {
                $key = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', $name))));
				$headers[$key] = $value;
			}
		}
		return $headers;
	}
1237912
private static function getResponseHeaders()
    {
        $arh = array();

        // headers_list don't return associative array
        $headers = headers_list();
        foreach ($headers as $header) {
            $header = explode(':', $header);
            $arh[array_shift($header)] = trim(implode(':', $header));
        }

        return $arh;
    }
366712
public static function GetHeaders()
	{
		$headers = false;

		if (function_exists('apache_request_headers')) $headers = apache_request_headers();

		if ($headers === false)
		{
			// apache_request_headers is not supported in this environment

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

		return $headers;
	}
468731
public function getHeaders()
    {
        // Define a headers array
        $headers = array();

        foreach ($this->attributes as $key => $value) {
            // Does our server attribute have our header prefix?
            if (self::hasPrefix($key, self::$http_header_prefix)) {
                // Add our server attribute to our header array
                $headers[
                    substr($key, strlen(self::$http_header_prefix))
                ] = $value;

            } elseif (in_array($key, self::$http_nonprefixed_headers)) {
                // Add our server attribute to our header array
                $headers[$key] = $value;
            }
        }

        return $headers;
    }
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;
  }
422381
def headers_as_list(self):
        
        headers = self.headers
        headers_list = ['{}: {}'.format(key, value) for key, value in iteritems(headers)]
        return headers_list
1274335
public String[] getHeaderNames() {
        Set<String> headers = this.headers.keySet();

        return headers.toArray(new String[headers.size()]);
    }
250712
public function getAll() : array
    {
        $headers = [];
        foreach ($this->headers as $h => $v) {
            $headers[] = $h.': '.$v;
        }

        return $headers;
    }