Skip to content

Commit 6094b5b

Browse files
committed
bug symfony#11516 [BrowserKit] Fix browser kit redirect with ports (dakota)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes symfony#11516). Discussion ---------- [BrowserKit] Fix browser kit redirect with ports | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | No ticket opened | License | MIT | Doc PR | None Whilst using Mink to do automated tests, I encountered a problem where redirects with ports would not work as the port was removed in the `updateServerFromURI()` method. This PR fixes the problem. During my testing I encountered `$client->followRedirects(false);` in the ClientTest class that was causing the redirectWithPort test to pass even though it should have been failing (Removing the line caused the test to correctly fail before the patch was written) Commits ------- 39973de [BrowserKit] Fix browser kit redirect with ports
2 parents e76561d + 39973de commit 6094b5b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Symfony/Component/BrowserKit/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ protected function requestFromRequest(Request $request, $changeHistory = true)
607607

608608
private function updateServerFromUri($server, $uri)
609609
{
610-
$server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST);
610+
$server['HTTP_HOST'] = $this->extractHost($uri);
611611
$scheme = parse_url($uri, PHP_URL_SCHEME);
612612
$server['HTTPS'] = null === $scheme ? $server['HTTPS'] : 'https' == $scheme;
613613
unset($server['HTTP_IF_NONE_MATCH'], $server['HTTP_IF_MODIFIED_SINCE']);

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,11 @@ public function testFollowRedirectWithPort()
484484
$headers = array(
485485
'HTTP_HOST' => 'www.example.com:8080',
486486
'HTTP_USER_AGENT' => 'Symfony2 BrowserKit',
487-
'HTTPS' => false
487+
'HTTPS' => false,
488+
'HTTP_REFERER' => 'http://www.example.com:8080/'
488489
);
489490

490491
$client = new TestClient();
491-
$client->followRedirects(false);
492492
$client->setNextResponse(new Response('', 302, array(
493493
'Location' => 'http://www.example.com:8080/redirected',
494494
)));

0 commit comments

Comments
 (0)