Skip to content

Commit cb7e78c

Browse files
bug #36592 [BrowserKit] Allow Referer set by history to be overridden (Slamdunk)
This PR was merged into the 3.4 branch. Discussion ---------- [BrowserKit] Allow Referer set by history to be overridden | Q | A | ------------- | --- | Branch? | 3.4, see #36591 for 5.0 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | Commits ------- 4774946 [BrowserKit] Allow Referer set by history to be overridden (3.4)
2 parents e696735 + 4774946 commit cb7e78c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 1 addition & 1 deletion
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

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Lines changed: 9 additions & 0 deletions
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)