Get the response headers as a string.

@param (bool) $status
(string) $eol

@since 3.0.0

@return string
480305
public function getHeadersAsString($status = true, $eol = "\n")
    {
        $headers = '';

        if ($status) {
            $headers = "HTTP/{$this->version} {$this->code} {$this->reasonPhrase}{$eol}";
        }

        foreach ($this->headers as $name => $value) {
            $headers .= "{$name}: {$value}{$eol}";
        }

        return $headers;
    }
631382
public function json($response, $status = 200)
    {
        $this->closeTransaction($status);
        return $this->_json($response, $status);
    }
186946
public function raw(string $data = '', int $status = 200): Response
    {
        $response = $this;

        // Headers
        $response = $response->withoutHeader('Content-Type')->withAddedHeader('Content-Type', 'text/plain');
        $this->getCharset() && $response = $response->withCharset($this->getCharset());

        // Content
        $data && $response = $response->withContent($data);

        // Status code
        $status && $response = $response->withStatus($status);

        return $response;
    }
440749
public function toString(): string
    {
        // first line
        $output = $this->buildFirstLine() . self::EOL;

        // add headers
        $output .= $this->headers->toHeaderLines(true);

        // append cookies
        if ($cookie = $this->cookies->toRequestHeader()) {
            $output .= "Cookie: $cookie" . self::EOL;
        }

        $output .= self::EOL;

        return $output . $this->getBody();
    }
1262952
public function prepareResponse($content, $status = null)
    {
        $response = new Response;

        $response->setContent($content);

        if (isset($status)) {
            $response->setStatusCode($status);
        }

        return $response->send();
    }
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;
    }
350446
protected function getResponseContent($ex, int $statusCode, array $headers) : string
    {
        return $this->getDefaultResponseContent($ex, $statusCode);
    }
161495
public static function toString($status)
    {
        switch ($status) {
            case self::DOWN_AVAILABLE:
                return 'Channel is down and available';
            case self::DOWN_RESERVED:
                return 'Channel is down, but reserved';
            case self::OFF_HOOK:
                return 'Channel is off hook';
            case self::DIGITS_DIALED:
                return 'Digits (or equivalent) have been dialed';
            case self::LINE_RINGING:
                return 'Line is ringing';
            case self::REMOTE_RINGING:
                return 'Remote end is ringing';
            case self::LINE_UP:
                return 'Line is up';
            case self::LINE_BUSY:
                return 'Line is busy';
            default:
                return false;
        }
    }
468287
public function generateStreamedResponse($status = 200, $headers = array())
	{
		$content = $this->generate();
		return new StreamedResponse(function () use ($content) {
			file_put_contents('php://output', $content);
		}, $status, $headers);
	}
1367075
private function header2Array($str)
    {
        if (is_array($str)) return $str;
        
        $result = [];
        $array = explode("\n", trim(str_replace("\r\n", "\n", $str), "\n"));
        foreach($array as $i => $line) {
            if ($i === 0) {
                $result['Http-Status'] = $line; // "HTTP/1.1 200 OK"
            } else {
                $header = explode(':', $line, 2);
                if (!$header[0]) continue;
                
                if (isset($header[1])) {
                    $result[trim($header[0])] = trim($header[1]);
                } else {
                    $result[] = trim($header[0]);
                }
            }
        }
        return $result;
    }
379460
private function parseStatusLine($headers): string {
        if (empty($headers)) {
            return '';
        }

        if (is_string($headers)) {
            if (preg_match_all('`(?:^|\n)(HTTP/[^\r]+)\r\n`', $headers, $matches)) {
                $firstLine = end($matches[1]);
            } else {
                $firstLine = trim(strstr($headers, "\r\n", true));
            }
        } else {
            $firstLine = (string)reset($headers);
        }

        // Test the status line.
        if (strpos($firstLine, 'HTTP/') === 0) {
            return $firstLine;
        }
        return '';
    }
850880
public function getHeader($field)
    {
       if (!isset($this->headers[$field])) {
           return null;
       }
       
       return is_array($this->headers[$field]) ? implode(',', $this->headers[$field]) : $this->headers[$field];
    }
628045
protected function getStatusString($status)
    {
        switch ($status) {
            case Values\Content\VersionInfo::STATUS_DRAFT:
                return 'DRAFT';

            case Values\Content\VersionInfo::STATUS_PUBLISHED:
                return 'PUBLISHED';

            case Values\Content\VersionInfo::STATUS_ARCHIVED:
                return 'ARCHIVED';
        }

        throw new RuntimeException('Undefined version status: ' . $status);
    }
225007
public static function header($name = null)
    {
        if (self::$reqHeaders === null) {
            self::generate();
        }

        if (is_string($name)) {
            $name = strtolower($name);
            return isset(self::$reqHeadersLower[$name]) ? self::$reqHeadersLower[$name] : false;
        }

        return self::$reqHeaders;
    }
885350
private function getHttpHeadersAsString($headers)
    {
        if (count($headers) == 0) {
            return '';
        }

        $max = max(array_map('strlen', array_keys($headers))) + 1;
        $content = '';
        ksort($headers);
        foreach ($headers as $name => $values) {
            foreach ($values as $value) {
                $content .= sprintf("%-{$max}s %s\r\n", $this->beautifyHeaderName($name).':', $value);
            }
        }

        return $content;
    }
234118
public function resourceJson($data = array(), $status = 200, array $headers = array())
  {
    $headers = array_merge($headers, $this->getRequestLimitHeader());
    $headers = array_merge($headers, $this->getConfig('headers'));

    return $this->getResponse()->resourceJson($data, $status, $headers);
  }
1134659
protected function html(string $html, int $status = 200, array $headers = []): ResponseInterface
    {
        return $this->responseFactory->createHtmlResponse($html, $status, $headers);
    }