From cc4b00347c9ff061488bc88194002be701f4190f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 29 Nov 2012 17:21:43 +0200 Subject: Added CI_Output::get_header() (an improved version of PR #645) Also fixed get_content_type() to only return the MIME value and created Output library unit tests for both of these methods. --- user_guide_src/source/changelog.rst | 3 ++- user_guide_src/source/libraries/output.rst | 30 +++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) (limited to 'user_guide_src/source') diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index ab1d99dab..09c425d0a 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -294,8 +294,9 @@ Release Date: Not Released - Added support for HTTP-Only cookies with new config option *cookie_httponly* (default FALSE). - Renamed method ``_call_hook()`` to ``call_hook()`` in the :doc:`Hooks Library `. - :doc:`Output Library ` changes include: - - Added method ``get_content_type()``. - Added a second argument to method ``set_content_type()`` that allows setting the document charset as well. + - Added method ``get_content_type()``. + - Added method ``get_header()``. - ``$config['time_reference']`` now supports all timezone strings supported by PHP. - :doc:`Config Library ` changes include: - Changed ``site_url()`` method to accept an array as well. diff --git a/user_guide_src/source/libraries/output.rst b/user_guide_src/source/libraries/output.rst index 82b1a56a5..a3d67b847 100644 --- a/user_guide_src/source/libraries/output.rst +++ b/user_guide_src/source/libraries/output.rst @@ -53,17 +53,37 @@ You can also set the character set of the document, by passing a second argument $this->output->set_content_type('css', 'utf-8'); -$this->output->get_content_type(); -========================================== +$this->output->get_content_type() +================================= -Returns the Content-Type HTTP header that's currently in use. +Returns the Content-Type HTTP header that's currently in use, +excluding the character set value. $mime = $this->output->get_content_type(); .. note:: If not set, the default return value is 'text/html'. -$this->output->get_output(); -============================= +$this->output->get_header() +=========================== + +Gets the requested HTTP header value, if set. + +If the header is not set, NULL will be returned. +If an empty value is passed to the method, it will return FALSE. + +Example:: + + $this->output->set_content_type('text/plain', 'UTF-8'); + echo $this->output->get_header('content-type'); + // Outputs: text/plain; charset=utf-8 + +.. note:: The header name is compared in a case-insensitive manner. + +.. note:: Raw headers sent via PHP's native ``header()`` function are + also detected. + +$this->output->get_output() +=========================== Permits you to manually retrieve any output that has been sent for storage in the output class. Usage example:: -- cgit v1.2.3-24-g4f1b