[BrowserKit] Pass headers when followRedirect()
is called
This commit is contained in:
parent
939f8720ac
commit
0d07af896b
@ -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