Skip to content

Commit

Permalink
Merge remote branch 'kriswallsmith/http/forwarded-secure'
Browse files Browse the repository at this point in the history
* kriswallsmith/http/forwarded-secure:
  [HttpFoundation] added support for X-Forwarded-Port request header
  • Loading branch information
fabpot committed May 4, 2011
2 parents e150ffd + ae46150 commit c200b42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Expand Up @@ -413,7 +413,7 @@ public function getScheme()

public function getPort()
{
return $this->server->get('SERVER_PORT');
return $this->headers->get('X-Forwarded-Port') ?: $this->server->get('SERVER_PORT');
}

/**
Expand Down
10 changes: 10 additions & 0 deletions tests/Symfony/Tests/Component/HttpFoundation/RequestTest.php
Expand Up @@ -711,4 +711,14 @@ public function testGetRequestFormat()
$this->assertEquals(null, $request->setRequestFormat('foo'));
$this->assertEquals('foo', $request->getRequestFormat(null));
}

public function testForwardedSecure()
{
$request = new Request();
$request->headers->set('X-Forwarded-Proto', 'https');
$request->headers->set('X-Forwarded-Port', 443);

$this->assertTrue($request->isSecure());
$this->assertEquals(443, $request->getPort());
}
}

0 comments on commit c200b42

Please sign in to comment.