merged branch stloyd/bugfix/issue7929 (PR #8697)
This PR was merged into the 2.2 branch.
Discussion
----------
[2.2] [BrowserKit] Pass headers when `followRedirect()` is called
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Tests pass? | yes
| Fixed tickets | #7929
| License | MIT
Commits
-------
0d07af8
[BrowserKit] Pass headers when `followRedirect()` is called
This commit is contained in:
commit
7e06905ec0
@ -420,7 +420,7 @@ abstract class Client
|
|||||||
throw new \LogicException('The request was not redirected.');
|
throw new \LogicException('The request was not redirected.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->request('get', $this->redirect);
|
return $this->request('get', $this->redirect, array(), array(), $this->history->current()->getServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -342,6 +342,33 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(array('foo' => 'bar'), $client->getRequest()->getCookies());
|
$this->assertEquals(array('foo' => 'bar'), $client->getRequest()->getCookies());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFollowRedirectWithHeaders()
|
||||||
|
{
|
||||||
|
$headers = array(
|
||||||
|
'HTTP_HOST' => 'www.example.com',
|
||||||
|
'HTTP_USER_AGENT' => 'Symfony2 BrowserKit',
|
||||||
|
'CONTENT_TYPE' => 'application/vnd.custom+xml',
|
||||||
|
'HTTPS' => false,
|
||||||
|
);
|
||||||
|
|
||||||
|
$client = new TestClient();
|
||||||
|
$client->followRedirects(false);
|
||||||
|
$client->setNextResponse(new Response('', 302, array(
|
||||||
|
'Location' => 'http://www.example.com/redirected',
|
||||||
|
)));
|
||||||
|
$client->request('GET', 'http://www.example.com/', array(), array(), array(
|
||||||
|
'CONTENT_TYPE' => 'application/vnd.custom+xml',
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertEquals($headers, $client->getRequest()->getServer());
|
||||||
|
|
||||||
|
$client->followRedirect();
|
||||||
|
|
||||||
|
$headers['HTTP_REFERER'] = 'http://www.example.com/';
|
||||||
|
|
||||||
|
$this->assertEquals($headers, $client->getRequest()->getServer());
|
||||||
|
}
|
||||||
|
|
||||||
public function testBack()
|
public function testBack()
|
||||||
{
|
{
|
||||||
$client = new TestClient();
|
$client = new TestClient();
|
||||||
|
Reference in New Issue
Block a user