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


PHP UriInterface::getUserInfo方法代码示例

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


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

示例1: 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.
  *
  * @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)
 {
     $request = clone $this;
     $request->scheme($uri->getScheme());
     $userInfo = $uri->getUserInfo();
     $parts = explode(':', $userInfo);
     $request->username($parts[0] ?: null);
     $request->password(!empty($parts[1]) ? $parts[1] : null);
     $request->port($uri->getPort());
     if ($preserveHost) {
         $host = $request->headers['Host'];
         $request->host($uri->getHost());
         $request->headers['Host'] = $host;
     } else {
         $request->host($uri->getHost());
     }
     $request->path($uri->getPath());
     $request->query($uri->getQuery());
     $request->fragment($uri->getFragment());
     return $request;
 }
开发者ID:crysalead,项目名称:net,代码行数:48,代码来源:RequestTrait.php

示例2: runMatches

 protected function runMatches(UriInterface $uri)
 {
     return $uri->getUserInfo() == $this->expected;
 }
开发者ID:oscarotero,项目名称:psr7-unitesting,代码行数:4,代码来源:UserInfo.php

示例3: obfuscateUri

 /**
  * Obfuscates URI if there is an username and a password present
  *
  * @param UriInterface $uri
  *
  * @return UriInterface
  */
 private static function obfuscateUri($uri)
 {
     $userInfo = $uri->getUserInfo();
     if (false !== ($pos = strpos($userInfo, ':'))) {
         return $uri->withUserInfo(substr($userInfo, 0, $pos), '***');
     }
     return $uri;
 }
开发者ID:dukt,项目名称:craft-oauth,代码行数:15,代码来源:RequestException.php

示例4: buildRequest

 private function buildRequest(Command $command, UriInterface $uri) : RequestInterface
 {
     $parameters = sprintf('-db=%s&%s', urlencode($this->database), $command);
     $body = new Stream('php://temp', 'wb+');
     $body->write($parameters);
     $body->rewind();
     $request = (new Request($uri->withUserInfo(''), 'POST'))->withAddedHeader('User-agent', 'SimpleFM')->withAddedHeader('Content-type', 'application/x-www-form-urlencoded')->withAddedHeader('Content-length', (string) strlen($parameters))->withBody($body);
     $credentials = urldecode($uri->getUserInfo());
     if ($command->hasIdentity()) {
         Assertion::notNull($this->identityHandler, 'An identity handler must be set to use identities on commands');
         $identity = $command->getIdentity();
         $credentials = sprintf('%s:%s', $identity->getUsername(), $this->identityHandler->decryptPassword($identity));
     }
     $this->logger->info(sprintf('%s?%s', (string) $uri->withUserInfo(''), $parameters));
     if ('' === $credentials) {
         return $request;
     }
     return $request->withAddedHeader('Authorization', sprintf('Basic %s', base64_encode($credentials)));
 }
开发者ID:soliantconsulting,项目名称:simplefm,代码行数:19,代码来源:Connection.php


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