From 00adf1d480f94692a625ec2165e0fcc9171c6e2f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 3 Apr 2012 12:30:50 +0300 Subject: Some improvements to the additions from pull #1234 --- system/core/Output.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/core/Output.php b/system/core/Output.php index 09d74f0c0..01fd1d867 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -220,24 +220,24 @@ class CI_Output { $this->headers[] = array($header, TRUE); return $this; } - + // -------------------------------------------------------------------- - + /** * Get Current Content Type Header - * Return text/html if Content-Type is not set * - * @return string + * @return string 'text/html', if not already set */ public function get_content_type() { - foreach ($this->headers as $header) + for ($i = 0, $c = count($this->headers); $i < $c; $i++) { - if (preg_match('/^Content-Type/', $header[0])) + if (preg_match('/^Content-Type:\s(.+)$/', $this->headers[$i][0], $matches)) { - return str_replace('Content-Type: ', '', $header[0]); + return $matches[1]; } } + return 'text/html'; } -- cgit v1.2.3-24-g4f1b