當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UriInterface::withHost方法代碼示例

本文整理匯總了PHP中Psr\Http\Message\UriInterface::withHost方法的典型用法代碼示例。如果您正苦於以下問題:PHP UriInterface::withHost方法的具體用法?PHP UriInterface::withHost怎麽用?PHP UriInterface::withHost使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Psr\Http\Message\UriInterface的用法示例。


在下文中一共展示了UriInterface::withHost方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getBaseUri

 /**
  * Generate the base URI to be used
  *
  * @param LeagueUriInterface|UriInterface $relative
  *
  * @return LeagueUriInterface|UriInterface
  */
 protected function getBaseUri($relative)
 {
     $userinfo = explode(':', $this->uri->getUserInfo(), 2);
     $user = array_shift($userinfo);
     $pass = array_shift($userinfo);
     return $relative->withHost($this->uri->getHost())->withScheme($this->uri->getScheme())->withUserInfo($user, $pass)->withPort($this->uri->getPort());
 }
開發者ID:burguin,項目名稱:test02,代碼行數:14,代碼來源:Resolve.php

示例2: withHost

 /**
  * Create an UriInterface with the host information from `$server`. It uses `$server['HTTP_HOST']` or
  * `$server['SERVER_NAME']` for this information.
  *
  * @param UriInterface $uri
  * @param array        $server
  *
  * @return UriInterface
  */
 private function withHost(UriInterface $uri, array $server) : UriInterface
 {
     if (isset($server['HTTP_HOST'])) {
         $server['HTTP_HOST'] = preg_replace('/:[0-9]+$/', '', $server['HTTP_HOST']);
         return $uri->withHost($server['HTTP_HOST']);
     } elseif (isset($server['SERVER_NAME'])) {
         return $uri->withHost($server['SERVER_NAME']);
     }
     return $uri;
 }
開發者ID:opsbears,項目名稱:piccolo-web-io-standard,代碼行數:19,代碼來源:StandardInputProcessor.php

示例3: withUri

 /**
  * Returns an instance with the provided URI.
  *
  * This method MUST update the Host header of the returned request by
  * default if the URI contains a host component. If the URI does not
  * contain a host component, any pre-existing Host header MUST be carried
  * over to the returned request.
  *
  * You can opt-in to preserving the original state of the Host header by
  * setting `$preserveHost` to `true`. When `$preserveHost` is set to
  * `true`, this method interacts with the Host header in the following ways:
  *
  * - If the the Host header is missing or empty, and the new URI contains
  *   a host component, this method MUST update the Host header in the returned
  *   request.
  * - If the Host header is missing or empty, and the new URI does not contain a
  *   host component, this method MUST NOT update the Host header in the returned
  *   request.
  * - If a Host header is present and non-empty, this method MUST NOT update
  *   the Host header in the returned request.
  *
  * This method MUST be implemented in such a way as to retain the
  * immutability of the message, and MUST return an instance that has the
  * new UriInterface instance.
  *
  * @link http://tools.ietf.org/html/rfc3986#section-4.3
  * @param UriInterface $uri New request URI to use.
  * @param bool $preserveHost Preserve the original state of the Host header.
  * @return self
  */
 public function withUri(UriInterface $uri, $preserveHost = false)
 {
     if (!$preserveHost) {
         $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '';
         $uri->withHost($host);
     }
     $this->_uri = $uri;
     return $this;
 }
開發者ID:TF-Joynic,項目名稱:Hydrogen,代碼行數:39,代碼來源:ServerRequest.php


注:本文中的Psr\Http\Message\UriInterface::withHost方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。