Skip to content

Commit

Permalink
bug #36592 [BrowserKit] Allow Referer set by history to be overridden…
Browse files Browse the repository at this point in the history
… (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)
  • Loading branch information
nicolas-grekas committed May 16, 2020
2 parents e696735 + 4774946 commit cb7e78c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/BrowserKit/Client.php
Expand Up @@ -294,7 +294,7 @@ public function request($method, $uri, array $parameters = [], array $files = []
$uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri);
}

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

Expand Down
9 changes: 9 additions & 0 deletions src/Symfony/Component/BrowserKit/Tests/ClientTest.php
Expand Up @@ -233,6 +233,15 @@ public function testRequestReferer()
$this->assertEquals('http://www.example.com/foo/foobar', $server['HTTP_REFERER'], '->request() sets the referer');
}

public function testRequestRefererCanBeOverridden()
{
$client = new TestClient();
$client->request('GET', 'http://www.example.com/foo/foobar');
$client->request('GET', 'bar', [], [], ['HTTP_REFERER' => 'xyz']);
$server = $client->getRequest()->getServer();
$this->assertEquals('xyz', $server['HTTP_REFERER'], '->request() allows referer to be overridden');
}

public function testRequestHistory()
{
$client = new TestClient();
Expand Down

0 comments on commit cb7e78c

Please sign in to comment.