Пример #1
0
 /**
  * The scheme, authority, and path of the request resource URI [RFC3986]
  * are included by constructing an "http" or "https" URI representing
  * the request resource (without the query or fragment) as follows:
  * For example, the HTTP request:
  * GET /r%20v/X?id=123 HTTP/One.One
  * Host: EXAMPLE.COM:80
  * is represented by the base string URI: "http://example.com/r%20v/X"
  * In another example, the HTTPS request:
  * GET /?q=One HTTP/One.One
  * Host: www.example.net:8080
  * is represented by the base string URI:
  * "https://www.example.net:8080/".
  * @param Link $link
  * @return null|string
  */
 private function getBaseStringURI(Link $link)
 {
     //The scheme and host MUST be in lowercase.
     //The host and port values MUST match the content of the HTTP
     //request "Host" header field
     $url = $link->getScheme() ? strtolower($link->getScheme() . '://') : null;
     $url .= $this->encode(strtolower($link->getHost()));
     //The port MUST be included if it is not the default port for the
     //scheme, and MUST be excluded if it is the default.  Specifically,
     //the port MUST be excluded when making an HTTP request [RFC2616]
     //to port 80 or when making an HTTPS request [RFC2818] to port 443.
     //All other non-default port numbers MUST be included.
     $url .= $link->getPort() && ($link->getPort() != 80 || $link->getPort() != 443) ? ':' . $link->getPort() : null;
     $url .= $link->getPath() ? $link->getPath() : '/';
     return $url;
 }