aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-06 23:30:46 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-06-06 23:30:46 +0200
commitf4f28b4d671ab0f2557dd12201e09fe19a27ba8d (patch)
treee3bcebe09d3473b0103e13f98e1c8e0216b1cc46
parent59c05b09236b3f4244b5d01897d923e0998a4b9d (diff)
downloadRouter-f4f28b4d671ab0f2557dd12201e09fe19a27ba8d.zip
Router-f4f28b4d671ab0f2557dd12201e09fe19a27ba8d.tar.gz
Router-f4f28b4d671ab0f2557dd12201e09fe19a27ba8d.tar.bz2
getDomain() support IPv6 and performances updated.
-rw-r--r--Http.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/Http.php b/Http.php
index 0d8f1f3..87316f0 100644
--- a/Http.php
+++ b/Http.php
@@ -676,13 +676,18 @@ class Http extends Generic implements \Hoa\Core\Parameter\Parameterizable {
*/
public static function getDomain ( ) {
- if('cli' === php_sapi_name())
- return '';
+ static $domain = null;
+
+ if(null === $domain) {
- $domain = $_SERVER['HTTP_HOST'];
+ if('cli' === php_sapi_name())
+ return $domain = '';
- if(false !== $pos = strpos($domain, ':'))
- return substr($domain, 0, $pos);
+ $domain = $_SERVER['HTTP_HOST'];
+
+ if(0 !== preg_match('#^(.+):' . static::getPort() . '$#', $domain, $m))
+ $domain = $m[1];
+ }
return $domain;
}