Skip to content

Commit

Permalink
Renaming RequestHandler::getReferrer to RequestHandler::getReferer fo…
Browse files Browse the repository at this point in the history
…r (mis)spelling consistency and deprecating the former
  • Loading branch information
ADmad committed Dec 20, 2009
1 parent f36e5ef commit d561405
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion cake/libs/controller/components/request_handler.php
Expand Up @@ -410,7 +410,7 @@ function setContent($name, $type = null) {
* @return string Server address
* @access public
*/
function getReferrer() {
function getReferer() {
if (env('HTTP_HOST') != null) {
$sessHost = env('HTTP_HOST');
}
Expand All @@ -421,6 +421,14 @@ function getReferrer() {
return trim(preg_replace('/(?:\:.*)/', '', $sessHost));
}

/**
* @deprecated use getReferer()
*/
function getReferrer() {
trigger_error('Deprecated method, use RequestHandlerComponent::getReferer instead', E_USER_WARNING);
return $this->getReferer();
}

/**
* Gets remote client IP
*
Expand Down
Expand Up @@ -530,10 +530,10 @@ function testCustomContent() {
*/
function testClientProperties() {
$_SERVER['HTTP_HOST'] = 'localhost:80';
$this->assertEqual($this->RequestHandler->getReferrer(), 'localhost');
$this->assertEqual($this->RequestHandler->getReferer(), 'localhost');
$_SERVER['HTTP_HOST'] = null;
$_SERVER['HTTP_X_FORWARDED_HOST'] = 'cakephp.org';
$this->assertEqual($this->RequestHandler->getReferrer(), 'cakephp.org');
$this->assertEqual($this->RequestHandler->getReferer(), 'cakephp.org');

$_SERVER['HTTP_X_FORWARDED_FOR'] = '192.168.1.5, 10.0.1.1, proxy.com';
$_SERVER['HTTP_CLIENT_IP'] = '192.168.1.2';
Expand Down

0 comments on commit d561405

Please sign in to comment.