Esempio n. 1
0
File: Oauth.php Progetto: seytar/psx
 /**
  * Normalize the url like defined in
  *
  * @see http://tools.ietf.org/html/rfc5849#section-3.4.1.2
  * @param \PSX\Url $url
  * @return false|string
  */
 public static function getNormalizedUrl(Url $url)
 {
     $scheme = $url->getScheme();
     $host = $url->getHost();
     $port = $url->getPort();
     $path = $url->getPath();
     // no port for 80 (http) and 443 (https)
     if (($port == 80 || empty($port)) && strcasecmp($scheme, 'http') == 0 || ($port == 443 || empty($port)) && strcasecmp($scheme, 'https') == 0) {
         $normalizedUrl = $scheme . '://' . $host . $path;
     } else {
         if (!empty($port)) {
             $normalizedUrl = $scheme . '://' . $host . ':' . $port . $path;
         } else {
             throw new Exception('No port specified');
         }
     }
     return strtolower($normalizedUrl);
 }