[BrowserKit] Fix #10641 : BrowserKit is broken when using ip as host

This commit is contained in:
Romain Neutron 2014-04-08 15:30:36 +02:00
parent 8aa194c0a6
commit e946da303d
2 changed files with 9 additions and 1 deletions

View File

@ -304,7 +304,7 @@ abstract class Client
$uri = $this->getAbsoluteUri($uri);
if (isset($server['HTTP_HOST'])) {
$uri = preg_replace('{^(https?\://)'.parse_url($uri, PHP_URL_HOST).'}', '\\1'.$server['HTTP_HOST'], $uri);
$uri = preg_replace('{^(https?\://)'.parse_url($uri, PHP_URL_HOST).'}', '${1}'.$server['HTTP_HOST'], $uri);
}
if (isset($server['HTTPS'])) {

View File

@ -103,6 +103,14 @@ class ClientTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('http://example.com/', $client->getRequest()->getUri(), '->getCrawler() returns the Request of the last request');
}
public function testGetRequestWithIpAsHost()
{
$client = new TestClient();
$client->request('GET', 'https://example.com/foo', array(), array(), array('HTTP_HOST' => '127.0.0.1'));
$this->assertEquals('https://127.0.0.1/foo', $client->getRequest()->getUri());
}
public function testGetResponse()
{
$client = new TestClient();