Moving features from RequestHandler into CakeRequest.

This commit is contained in:
Mark Story 2010-05-08 00:36:03 -04:00
parent df910026ee
commit 78bd7300a2
2 changed files with 9 additions and 0 deletions

View file

@ -380,6 +380,11 @@ class CakeRequest implements ArrayAccess {
*/ */
public function referer($local = false) { public function referer($local = false) {
$ref = env('HTTP_REFERER'); $ref = env('HTTP_REFERER');
$forwarded = env('HTTP_X_FORWARDED_HOST');
if ($forwarded) {
$ref = $forwarded;
}
$base = ''; $base = '';
if (defined('FULL_BASE_URL')) { if (defined('FULL_BASE_URL')) {
$base = FULL_BASE_URL; $base = FULL_BASE_URL;

View file

@ -466,6 +466,10 @@ class CakeRequestTestCase extends CakeTestCase {
$_SERVER['HTTP_REFERER'] = FULL_BASE_URL . 'recipes/add'; $_SERVER['HTTP_REFERER'] = FULL_BASE_URL . 'recipes/add';
$result = $request->referer(true); $result = $request->referer(true);
$this->assertIdentical($result, '/recipes/add'); $this->assertIdentical($result, '/recipes/add');
$_SERVER['HTTP_X_FORWARDED_HOST'] = 'cakephp.org';
$result = $request->referer();
$this->assertIdentical($result, 'cakephp.org');
} }
/** /**