Skip to content

Commit 1467e0c

Browse files
committed
[BrowserKit] Allow Referer set by history to be overridden (3.4)
1 parent 1c7bcd9 commit 1467e0c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public function request($method, $uri, array $parameters = [], array $files = []
294294
$uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri);
295295
}
296296

297-
if (!$this->history->isEmpty()) {
297+
if (!isset($server['HTTP_REFERER']) && !$this->history->isEmpty()) {
298298
$server['HTTP_REFERER'] = $this->history->current()->getUri();
299299
}
300300

Tests/ClientTest.php

+9
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,15 @@ public function testRequestReferer()
233233
$this->assertEquals('http://www.example.com/foo/foobar', $server['HTTP_REFERER'], '->request() sets the referer');
234234
}
235235

236+
public function testRequestRefererCanBeOverridden()
237+
{
238+
$client = new TestClient();
239+
$client->request('GET', 'http://www.example.com/foo/foobar');
240+
$client->request('GET', 'bar', [], [], ['HTTP_REFERER' => 'xyz']);
241+
$server = $client->getRequest()->getServer();
242+
$this->assertEquals('xyz', $server['HTTP_REFERER'], '->request() allows referer to be overridden');
243+
}
244+
236245
public function testRequestHistory()
237246
{
238247
$client = new TestClient();

0 commit comments

Comments
 (0)