mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 18:22:41 +01:00
Make AphrontRequest::getHost() work properly in the presence of a port
Summary: This currently gives us back "domain.com:port" if there's a port, which messes up the new Phame logic. Make `getHost()` do what one would reasonably expect it to. Test Plan: Loaded my local, which is on 8080. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D3571
This commit is contained in:
parent
054ea7dc4a
commit
a0070d8bf4
1 changed files with 8 additions and 6 deletions
|
@ -60,7 +60,10 @@ final class AphrontRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function getHost() {
|
final public function getHost() {
|
||||||
return $this->host;
|
// The "Host" header may include a port number; if so, ignore it. We can't
|
||||||
|
// use PhutilURI since there's no URI scheme.
|
||||||
|
list($actual_host) = explode(':', $this->host, 2);
|
||||||
|
return $actual_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -272,13 +275,12 @@ final class AphrontRequest {
|
||||||
$base_domain = $base_uri->getDomain();
|
$base_domain = $base_uri->getDomain();
|
||||||
$base_protocol = $base_uri->getProtocol();
|
$base_protocol = $base_uri->getProtocol();
|
||||||
|
|
||||||
// The "Host" header may include a port number; if so, ignore it. We can't
|
$host = $this->getHost();
|
||||||
// use PhutilURI since there's no URI scheme.
|
|
||||||
list($actual_host) = explode(':', $this->getHost(), 2);
|
if ($base_domain != $host) {
|
||||||
if ($base_domain != $actual_host) {
|
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"This install of Phabricator is configured as '{$base_domain}' but ".
|
"This install of Phabricator is configured as '{$base_domain}' but ".
|
||||||
"you are accessing it via '{$actual_host}'. Access Phabricator via ".
|
"you are accessing it via '{$host}'. Access Phabricator via ".
|
||||||
"the primary configured domain.");
|
"the primary configured domain.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue