From 78bd7300a2c50e92af52c9a2da2221499909ed92 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 8 May 2010 00:36:03 -0400 Subject: [PATCH] Moving features from RequestHandler into CakeRequest. --- cake/libs/cake_request.php | 5 +++++ cake/tests/cases/libs/cake_request.test.php | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/cake/libs/cake_request.php b/cake/libs/cake_request.php index c55f31866..438c4af4e 100644 --- a/cake/libs/cake_request.php +++ b/cake/libs/cake_request.php @@ -380,6 +380,11 @@ class CakeRequest implements ArrayAccess { */ public function referer($local = false) { $ref = env('HTTP_REFERER'); + $forwarded = env('HTTP_X_FORWARDED_HOST'); + if ($forwarded) { + $ref = $forwarded; + } + $base = ''; if (defined('FULL_BASE_URL')) { $base = FULL_BASE_URL; diff --git a/cake/tests/cases/libs/cake_request.test.php b/cake/tests/cases/libs/cake_request.test.php index b9eb4b8a2..8b6531dc4 100644 --- a/cake/tests/cases/libs/cake_request.test.php +++ b/cake/tests/cases/libs/cake_request.test.php @@ -466,6 +466,10 @@ class CakeRequestTestCase extends CakeTestCase { $_SERVER['HTTP_REFERER'] = FULL_BASE_URL . 'recipes/add'; $result = $request->referer(true); $this->assertIdentical($result, '/recipes/add'); + + $_SERVER['HTTP_X_FORWARDED_HOST'] = 'cakephp.org'; + $result = $request->referer(); + $this->assertIdentical($result, 'cakephp.org'); } /**