diff options
author | Andrey Andreev <narf@devilix.net> | 2014-01-09 18:21:26 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-01-09 18:21:26 +0100 |
commit | a0a73c977ce25911f56948d89de817b3ca83adcb (patch) | |
tree | bc92f331696689799c566216e594efcfeb71ced5 | |
parent | f74abcbed6efe1992f05430f2e4483e54fbcbf86 (diff) |
Add HTTP response code 307 support in URL helper redirect()
-rw-r--r-- | system/helpers/url_helper.php | 15 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 2 |
2 files changed, 11 insertions, 6 deletions
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index f819b96e9..f9650cd04 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -532,11 +532,16 @@ if ( ! function_exists('redirect')) } elseif ($method !== 'refresh' && (empty($code) OR ! is_numeric($code))) { - // Reference: http://en.wikipedia.org/wiki/Post/Redirect/Get - $code = (isset($_SERVER['REQUEST_METHOD'], $_SERVER['SERVER_PROTOCOL']) - && $_SERVER['REQUEST_METHOD'] === 'POST' - && $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.1') - ? 303 : 302; + if (isset($_SERVER['SERVER_PROTOCOL'], $_SERVER['REQUEST_METHOD']) && $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.1') + { + $code = ($_SERVER['REQUEST_METHOD'] !== 'GET') + ? 303 // reference: http://en.wikipedia.org/wiki/Post/Redirect/Get + : 307; + } + else + { + $code = 302; + } } switch ($method) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index e83598cb4..0488d9d4a 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -77,7 +77,7 @@ Release Date: Not Released - :php:func:`url_title()` will now trim extra dashes from beginning and end. - :php:func:`anchor_popup()` will now fill the *href* attribute with the URL and its JS code will return FALSE instead. - Added JS window name support to the :php:func:`anchor_popup()` function. - - Added support (auto-detection) for HTTP/1.1 response code 303 in :php:func:`redirect()`. + - Added support (auto-detection) for HTTP/1.1 response codes 303, 307 in :php:func:`redirect()`. - Changed :php:func:`redirect()` to choose the **refresh** method only on IIS servers, instead of all servers on Windows (when **auto** is used). - Changed :php:func:`anchor()`, :php:func:`anchor_popup()`, and :php:func:`redirect()` to support protocol-relative URLs (e.g. *//ellislab.com/codeigniter*). |