bug #10078 [BrowserKit] add non-standard port to HTTP_HOST server param (kbond)
This PR was submitted for the 2.3-dev branch but it was merged into the 2.3 branch instead (closes #10078). Discussion ---------- [BrowserKit] add non-standard port to HTTP_HOST server param | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | https://github.com/Behat/MinkGoutteDriver/issues/25 | License | MIT | Doc PR | n/a This fix will allow using BrowserKit with php's webserver. Commits ------- 5f25639 [BrowserKit] add non-standard port to HTTP_HOST
This commit is contained in:
commit
3ce5ac084e
@ -302,12 +302,18 @@ abstract class Client
|
||||
}
|
||||
|
||||
$uri = $this->getAbsoluteUri($uri);
|
||||
|
||||
$server = array_merge($this->server, $server);
|
||||
|
||||
if (!$this->history->isEmpty()) {
|
||||
$server['HTTP_REFERER'] = $this->history->current()->getUri();
|
||||
}
|
||||
|
||||
$server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST);
|
||||
|
||||
if ($port = parse_url($uri, PHP_URL_PORT)) {
|
||||
$server['HTTP_HOST'] .= ':'.$port;
|
||||
}
|
||||
|
||||
$server['HTTPS'] = 'https' == parse_url($uri, PHP_URL_SCHEME);
|
||||
|
||||
$this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar->allValues($uri), $server, $content);
|
||||
|
@ -160,6 +160,11 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$client->request('GET', 'https://www.example.com');
|
||||
$headers = $client->getRequest()->getServer();
|
||||
$this->assertTrue($headers['HTTPS'], '->request() sets the HTTPS header');
|
||||
|
||||
$client = new TestClient();
|
||||
$client->request('GET', 'http://www.example.com:8080');
|
||||
$headers = $client->getRequest()->getServer();
|
||||
$this->assertEquals('www.example.com:8080', $headers['HTTP_HOST'], '->request() sets the HTTP_HOST header with port');
|
||||
}
|
||||
|
||||
public function testRequestURIConversion()
|
||||
@ -448,6 +453,24 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($headers, $client->getRequest()->getServer());
|
||||
}
|
||||
|
||||
public function testFollowRedirectWithPort()
|
||||
{
|
||||
$headers = array(
|
||||
'HTTP_HOST' => 'www.example.com:8080',
|
||||
'HTTP_USER_AGENT' => 'Symfony2 BrowserKit',
|
||||
'HTTPS' => false
|
||||
);
|
||||
|
||||
$client = new TestClient();
|
||||
$client->followRedirects(false);
|
||||
$client->setNextResponse(new Response('', 302, array(
|
||||
'Location' => 'http://www.example.com:8080/redirected',
|
||||
)));
|
||||
$client->request('GET', 'http://www.example.com:8080/');
|
||||
|
||||
$this->assertEquals($headers, $client->getRequest()->getServer());
|
||||
}
|
||||
|
||||
public function testBack()
|
||||
{
|
||||
$client = new TestClient();
|
||||
|
Reference in New Issue
Block a user