当前位置: 首页>>代码示例>>PHP>>正文


PHP UriInterface::getHost方法代码示例

本文整理汇总了PHP中Psr\Http\Message\UriInterface::getHost方法的典型用法代码示例。如果您正苦于以下问题:PHP UriInterface::getHost方法的具体用法?PHP UriInterface::getHost怎么用?PHP UriInterface::getHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Psr\Http\Message\UriInterface的用法示例。


在下文中一共展示了UriInterface::getHost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleRequest

 /**
  * {@inheritdoc}
  */
 public function handleRequest(RequestInterface $request, callable $next, callable $first)
 {
     if ($this->replace || $request->getUri()->getHost() === '') {
         $uri = $request->getUri()->withHost($this->host->getHost())->withScheme($this->host->getScheme())->withPort($this->host->getPort());
         $request = $request->withUri($uri);
     }
     return $next($request);
 }
开发者ID:php-http,项目名称:client-common,代码行数:11,代码来源:AddHostPlugin.php

示例2: withUri

 function withUri(UriInterface $uri, $preserveHost = FALSE) : self
 {
     $headers = $this->headers;
     $headers['HOST'] = $headers['HOST'] ?? [];
     if (!$preserveHost && $uri->getHost()) {
         $headers['HOST'] = [$uri->getHost()];
     }
     $new = clone $this;
     $new->headers = $headers;
     $new->headerNames['HOST'] = 'Host';
     $new->uri = parse_url((string) $uri);
     return $new;
 }
开发者ID:guide42,项目名称:ochenta,代码行数:13,代码来源:RequestTrait.php

示例3: isFiltered

 public function isFiltered(UriInterface $currentUri, UriInterface $startUri)
 {
     /* @var $currentUri Uri */
     /* @var $startUri Uri */
     $startDomainElements = explode('.', $startUri->getHost());
     $currentDomainElements = explode('.', $currentUri->getHost());
     $startDomainLength = count($startDomainElements);
     $currentDomainLength = count($currentDomainElements);
     if ($currentDomainLength < $startDomainLength) {
         return true;
     }
     return $currentUri->getHost($startDomainLength) !== $startUri->getHost($startDomainLength);
 }
开发者ID:phmlabs,项目名称:smoke,代码行数:13,代码来源:ForeignDomainFilter.php

示例4: withUri

 public function withUri(UriInterface $uri, $preserveHost = false)
 {
     $request = clone $this;
     $request->uri = $uri;
     if ($preserveHost || !$uri->getHost()) {
         return $request;
     }
     $host = $uri->getHost();
     if ($uri->getPort()) {
         $host .= ':' . $uri->getPort();
     }
     $request->withHeader('host', $host);
     return $request;
 }
开发者ID:packaged,项目名称:http,代码行数:14,代码来源:Request.php

示例5: withUri

 public function withUri(Psr7UriInterface $uri, $preserveHost = false)
 {
     $new = clone $this;
     $new->uri = $uri;
     $uriHost = $uri->getHost();
     $requestHost = $new->getHeaderLine('Host');
     if (!$preserveHost && $uriHost !== $requestHost) {
         return $new->withHeader('Host', $uriHost);
     }
     return $new;
 }
开发者ID:cerad,项目名称:http,代码行数:11,代码来源:Request.php

示例6: withUri

 public function withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = false)
 {
     $request = clone $this;
     $request->uri = $uri;
     if (!$preserveHost or !$this->hasHeader('Host')) {
         $host = $uri->getHost();
         if ($host != '') {
             $request->setHeader('Host', $host);
         }
     }
     return $request;
 }
开发者ID:jivoo,项目名称:http,代码行数:12,代码来源:RequestTrait.php

示例7: withUri

 public function withUri(UriInterface $uri, $preserveHost = false)
 {
     $clone = clone $this;
     $clone->uri = $uri;
     if (!$preserveHost) {
         if ($host = $uri->getHost()) {
             if ($port = $uri->getPort()) {
                 $host .= ':' . $port;
             }
             return $clone->widthHeader('host', $host);
         }
     }
     return $clone;
 }
开发者ID:lynxgroup,项目名称:http,代码行数:14,代码来源:Request.php

示例8: withUri

 /**
  * @param \Psr\Http\Message\UriInterface $uri
  * @param bool $preserveHost
  * @return static
  */
 public function withUri(UriInterface $uri, $preserveHost = false)
 {
     $new = clone $this;
     $new->uri = $uri;
     if ($preserveHost || '' === ($host = $uri->getHost())) {
         return $new;
     }
     if ('' !== ($port = $uri->getPort())) {
         $host .= ':' . $port;
     }
     $new->headerNames['host'] = 'Host';
     $new->headers['Host'] = [$host];
     return $new;
 }
开发者ID:Golpha,项目名称:Http,代码行数:19,代码来源:RequestTrait.php

示例9: withUri

 public function withUri(\Psr\Http\Message\UriInterface $uri, $preserveHost = false)
 {
     if ($uri === $this->uri) {
         return $this;
     }
     $new = clone $this;
     $new->uri = $uri;
     if ($preserveHost) {
         return $new;
     }
     if ($host = $uri->getHost()) {
         $new->updateFromUri($host);
     }
     return $new;
 }
开发者ID:eksith,项目名称:Blog,代码行数:15,代码来源:Request.php

示例10: filterBaseurl

 /**
  * @param  \Psr\Http\Message\UriInterface $uri
  * @return string
  */
 protected function filterBaseurl(UriInterface $uri)
 {
     if ($baseUrl = $this->settings['baseurl']) {
         $reqUri = $uri->getScheme() . '://' . $uri->getHost();
         if ($port = $uri->getPort()) {
             $reqUri .= ':' . $port;
         }
         $url = parse_url($baseUrl);
         $uri = $uri->withScheme($url['scheme'])->withHost($url['host']);
         if ($port || isset($url['port'])) {
             $port = $port == $url['port'] ? $port : $url['port'];
             $uri = $uri->withPort($port);
         }
         return $reqUri !== rtrim($baseUrl, '/');
     }
     return false;
 }
开发者ID:ninjanero,项目名称:slim-skeleton,代码行数:21,代码来源:CommonMiddleware.php

示例11: updateHostFromUri

 /**
  * Retrieve the host from the URI instance
  */
 private function updateHostFromUri()
 {
     $host = $this->uri->getHost();
     if ($host == '') {
         return;
     }
     if (($port = $this->uri->getPort()) !== null) {
         $host .= ':' . $port;
     }
     if (isset($this->headerNames['host'])) {
         $header = $this->headerNames['host'];
     } else {
         $header = 'Host';
         $this->headerNames['host'] = 'Host';
     }
     // Ensure Host is the first header.
     // See: http://tools.ietf.org/html/rfc7230#section-5.4
     $this->headers = [$header => [$host]] + $this->headers;
 }
开发者ID:narrowspark,项目名称:framework,代码行数:22,代码来源:Request.php

示例12: all

 /**
  * Get each invalidation request replicated over all HTTP caching servers
  *
  * @return RequestInterface[]
  */
 public function all()
 {
     $requests = [];
     foreach ($this->queue as $request) {
         $uri = $request->getUri();
         // If a base URI is configured, try to make partial invalidation
         // requests complete.
         if ($this->baseUri) {
             if ($uri->getHost()) {
                 // Absolute URI: does it already have a scheme?
                 if (!$uri->getScheme() && $this->baseUri->getScheme() !== '') {
                     $uri = $uri->withScheme($this->baseUri->getScheme());
                 }
             } else {
                 // Relative URI
                 if ($this->baseUri->getHost() !== '') {
                     $uri = $uri->withHost($this->baseUri->getHost());
                 }
                 if ($this->baseUri->getPort()) {
                     $uri = $uri->withPort($this->baseUri->getPort());
                 }
                 // Base path
                 if ($this->baseUri->getPath() !== '') {
                     $path = $this->baseUri->getPath() . '/' . ltrim($uri->getPath(), '/');
                     $uri = $uri->withPath($path);
                 }
             }
         }
         // Close connections to make sure invalidation (PURGE/BAN) requests
         // will not interfere with content (GET) requests.
         $request = $request->withUri($uri)->withHeader('Connection', 'Close');
         // Create a request to each caching proxy server
         foreach ($this->servers as $server) {
             $requests[] = $request->withUri($uri->withScheme($server->getScheme())->withHost($server->getHost())->withPort($server->getPort()), true);
         }
     }
     return $requests;
 }
开发者ID:heartshare,项目名称:FOSHttpCache,代码行数:43,代码来源:RequestQueue.php

示例13: getHostFromUri

 /**
  * Retrieve the host from the URI instance
  *
  * @return string
  */
 private function getHostFromUri()
 {
     $host = $this->uri->getHost();
     $host .= $this->uri->getPort() ? ':' . $this->uri->getPort() : '';
     return $host;
 }
开发者ID:DenLilleMand,项目名称:christianssite,代码行数:11,代码来源:RequestTrait.php

示例14: withUri

 /**
  * {@inheritdoc}
  */
 public function withUri(UriInterface $uri, $preserveHost = false)
 {
     $newInstance = clone $this;
     $newInstance->uri = $uri;
     if ($preserveHost) {
         return $newInstance;
     }
     if ($uri->getHost() && !$this->hasHeader('Host')) {
         $host = $uri->getHost();
         $host .= !is_null($uri->getPort()) ? ':' . $uri->getPort() : '';
         $newInstance->headerNames['host'] = 'Host';
         $newInstance->headerValues['host'] = $host;
     }
     return $newInstance;
 }
开发者ID:radphp,项目名称:network,代码行数:18,代码来源:Request.php

示例15: checkUrl

 /**
  * {@inheritDoc}
  */
 public function checkUrl(UriInterface $uriInterface)
 {
     return preg_match('/imdb\\.com$/', (string) $uriInterface->getHost());
 }
开发者ID:najaram,项目名称:moviefetcher,代码行数:7,代码来源:ImdbParser.php


注:本文中的Psr\Http\Message\UriInterface::getHost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。