diff --git a/src/p3k/HTTP/Test.php b/src/p3k/HTTP/Test.php index 37219ef..3efa2d8 100644 --- a/src/p3k/HTTP/Test.php +++ b/src/p3k/HTTP/Test.php @@ -33,7 +33,7 @@ class Test implements Transport { $this->_redirects_remaining = $this->_max_redirects; $parts = parse_url($url); unset($parts['fragment']); - $url = \build_url($parts); + $url = self::_build_url($parts); return $this->_read_file($url); } @@ -57,7 +57,7 @@ class Test implements Transport { $parts = parse_url($url); if($parts['path']) { $parts['path'] = '/'.str_replace('/','_',substr($parts['path'],1)); - $url = \build_url($parts); + $url = self::_build_url($parts); } $filename = $this->_testDataPath.preg_replace('/https?:\/\//', '', $url); @@ -135,4 +135,17 @@ class Test implements Transport { return $retVal; } + private static function _build_url($parsed_url) { + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; + $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; + $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; + $user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; + $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : ''; + $pass = ($user || $pass) ? "$pass@" : ''; + $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; + $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; + $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; + return "$scheme$user$pass$host$port$path$query$fragment"; + } + }