Permalink
Browse files

BUGFIX Don't' set 'Referer' header in FunctionalTest->get()/post() if…

… its explicitly passed to the method
  • Loading branch information...
1 parent 20a8379 commit 1f7f8b8aee67181bd91a0c0dba7786ac9da1c1e6 @chillu chillu committed May 4, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 dev/TestSession.php
View
@@ -43,7 +43,7 @@ function __destruct() {
*/
function get($url, $session = null, $headers = null, $cookies = null) {
$headers = (array) $headers;
- if($this->lastUrl) $headers['Referer'] = $this->lastUrl;
+ if($this->lastUrl && !isset($headers['Referer'])) $headers['Referer'] = $this->lastUrl;
$this->lastResponse = Director::test($url, null, $session ? $session : $this->session, null, null, $headers, $cookies);
$this->lastUrl = $url;
if(!$this->lastResponse) user_error("Director::test($url) returned null", E_USER_WARNING);
@@ -56,7 +56,7 @@ function get($url, $session = null, $headers = null, $cookies = null) {
*/
function post($url, $data, $headers = null, $session = null, $body = null, $cookies = null) {
$headers = (array) $headers;
- if($this->lastUrl) $headers['Referer'] = $this->lastUrl;
+ if($this->lastUrl && !isset($headers['Referer'])) $headers['Referer'] = $this->lastUrl;
$this->lastResponse = Director::test($url, $data, $session ? $session : $this->session, null, $body, $headers, $cookies);
$this->lastUrl = $url;
if(!$this->lastResponse) user_error("Director::test($url) returned null", E_USER_WARNING);

0 comments on commit 1f7f8b8

Please sign in to comment.