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


PHP RequestInterface::getHost方法代码示例

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


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

示例1: checkRequest

 /**
  * @param RequestInterface $actual
  * @param RequestInterface $expected
  * @throws FailedRequestExpectationException
  */
 public static function checkRequest(RequestInterface $actual, RequestInterface $expected)
 {
     self::checkIsEqual($actual->getHost(), $expected->getHost(), 'host');
     self::checkIsEqual($actual->getPath(), $expected->getPath(), 'url path');
     self::checkIsEqual($actual->getMethod(), $expected->getMethod(), 'http method');
     self::checkRequestQuery($actual, $expected);
     self::checkContentType($actual, $expected);
     self::checkRequestBody($actual, $expected);
 }
开发者ID:lezhnev74,项目名称:GuzzleHttpMock,代码行数:14,代码来源:RequestChecker.php

示例2: getRequestAndQuery

 /**
  * @param RequestInterface $request
  * @return array ['query' => ..., 'request' => ...]
  */
 protected function getRequestAndQuery(RequestInterface $request)
 {
     $query = [];
     foreach ($request->getQuery() as $param => $val) {
         $query[$param] = $val;
     }
     $requestInfo = ['url' => $request->getUrl(), 'path' => $request->getPath(), 'queryString' => (string) $request->getQuery(), 'method' => $request->getMethod(), 'hostname' => $request->getHost(), 'port' => $request->getPort(), 'resource' => $request->getResource()];
     return ['query' => $query, 'request' => $requestInfo];
 }
开发者ID:keboola,项目名称:generic-extractor,代码行数:13,代码来源:AbstractSignature.php

示例3: let

 function let(SiteConfigBuilder $siteConfigBuilder, SiteConfig $siteConfig, Factory $authenticatorFactory, ClientInterface $guzzle, Emitter $emitter, BeforeEvent $beforeEvent, CompleteEvent $completeEvent, RequestInterface $request, ResponseInterface $response, Factory $authenticatorFactory)
 {
     $siteConfig->getHost()->willReturn('example.com');
     $siteConfigBuilder->buildForHost('example.com')->willReturn($siteConfig);
     $guzzle->getEmitter()->willReturn($emitter);
     $request->getHost()->willReturn('example.com');
     $beforeEvent->getRequest()->willReturn($request);
     $beforeEvent->getClient()->willReturn($guzzle);
     $response->getBody()->willReturn('<html></html>');
     $completeEvent->getResponse()->willReturn($response);
     $completeEvent->getRequest()->willReturn($request);
     $completeEvent->getClient()->willReturn($guzzle);
     $this->beConstructedWith($siteConfigBuilder, $authenticatorFactory);
 }
开发者ID:bdunogier,项目名称:guzzle-site-authenticator,代码行数:14,代码来源:AuthenticatorSubscriberSpec.php

示例4: signRequest

 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     /** @var PostBodyInterface $body */
     $body = $request->getBody();
     $body->setField('Timestamp', gmdate('c'));
     $body->setField('SignatureVersion', '2');
     $body->setField('SignatureMethod', 'HmacSHA256');
     $body->setField('AWSAccessKeyId', $credentials->getAccessKeyId());
     if ($token = $credentials->getSecurityToken()) {
         $body->setField('SecurityToken', $token);
     }
     // build string to sign
     $sign = $request->getMethod() . "\n" . $request->getHost() . "\n" . '/' . "\n" . $this->getCanonicalizedParameterString($body);
     $request->getConfig()->set('aws.signature', $sign);
     $body->setField('Signature', base64_encode(hash_hmac('sha256', $sign, $credentials->getSecretKey(), true)));
 }
开发者ID:briareos,项目名称:aws-sdk-php,代码行数:16,代码来源:SignatureV2.php

示例5: add_cookies

 private function add_cookies(RequestInterface $request, $value)
 {
     if ($value === true) {
         static $cookie = null;
         if (!$cookie) {
             $cookie = new Cookie();
         }
         $request->getEmitter()->attach($cookie);
     } elseif (is_array($value)) {
         $request->getEmitter()->attach(new Cookie(CookieJar::fromArray($value, $request->getHost())));
     } elseif ($value instanceof CookieJarInterface) {
         $request->getEmitter()->attach(new Cookie($value));
     } elseif ($value !== false) {
         throw new \InvalidArgumentException('cookies must be an array, ' . 'true, or a CookieJarInterface object');
     }
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:16,代码来源:MessageFactory.php

示例6: addCookieHeader

 public function addCookieHeader(RequestInterface $request)
 {
     $values = array();
     $scheme = $request->getScheme();
     $host = $request->getHost();
     $path = $request->getPath();
     foreach ($this->cookies as $cookie) {
         if ($cookie->matchesPath($path) && $cookie->matchesDomain($host) && !$cookie->isExpired() && (!$cookie->getSecure() || $scheme == 'https')) {
             $values[] = $cookie->getName() . '=' . self::getCookieValue($cookie->getValue());
         }
     }
     if ($values) {
         $request->setHeader('Cookie', implode('; ', $values));
     }
 }
开发者ID:bobozhangshao,项目名称:HeartCare,代码行数:15,代码来源:CookieJar.php

示例7: extractCookiesArgument

 /**
  * @param RequestInterface $request
  */
 protected function extractCookiesArgument(RequestInterface $request)
 {
     $listeners = $request->getEmitter()->listeners('before');
     foreach ($listeners as $listener) {
         if ($listener[0] instanceof Cookie) {
             $values = [];
             $scheme = $request->getScheme();
             $host = $request->getHost();
             $path = $request->getPath();
             /** @var SetCookie $cookie */
             foreach ($listener[0]->getCookieJar() as $cookie) {
                 if ($cookie->matchesPath($path) && $cookie->matchesDomain($host) && !$cookie->isExpired() && (!$cookie->getSecure() || $scheme == 'https')) {
                     $values[] = $cookie->getName() . '=' . CookieJar::getCookieValue($cookie->getValue());
                 }
             }
             if ($values) {
                 $this->addOption('b', escapeshellarg(implode('; ', $values)));
             }
         }
     }
 }
开发者ID:mdrost,项目名称:cuzzle,代码行数:24,代码来源:CurlFormatter.php

示例8: getParameters

 /**
  * Get context fields to add to the time-line entry.
  *
  * @param RequestInterface  $request
  * @param ResponseInterface $response
  * @param Exception         $error
  *
  * @return array
  */
 protected function getParameters(RequestInterface $request, ResponseInterface $response = null, Exception $error = null)
 {
     $params = [];
     $keys = array_intersect($this->context, $this->availableParameters);
     foreach ($keys as $key) {
         switch ($key) {
             case 'request':
                 $result = $request;
                 break;
             case 'response':
                 $result = $response;
                 break;
             case 'method':
                 $result = $request->getMethod();
                 break;
             case 'url':
                 $result = $request->getUrl();
                 break;
             case 'resource':
                 $result = $request->getResource();
                 break;
             case 'request_version':
                 $result = $request->getProtocolVersion();
                 break;
             case 'response_version':
                 $result = $response ? $response->getProtocolVersion() : 'NULL';
                 break;
             case 'host':
                 $result = $request->getHost();
                 break;
             case 'hostname':
                 $result = gethostname();
                 break;
             case 'status_code':
                 $result = $response ? $response->getStatusCode() : 'NULL';
                 break;
             case 'phrase':
                 $result = $response ? $response->getReasonPhrase() : 'NULL';
                 break;
             case 'error':
                 $result = $error ? $error->getMessage() : 'NULL';
                 break;
         }
         $params[$key] = (string) $result ?: '';
     }
     return $params;
 }
开发者ID:jezzdk,项目名称:guzzle-debugbar,代码行数:56,代码来源:DebugbarSubscriber.php

示例9: save

 /**
  * Save data
  *
  * @author  Florian Preusner
  * @version 2.1
  * @since   2015-05
  *
  * @param   RequestInterface $request
  */
 public function save(RequestInterface $request)
 {
     $this->setHost($request->getHost());
 }
开发者ID:Virakal,项目名称:GuzzleBundle,代码行数:13,代码来源:LogRequest.php

示例10: buildSiteConfig

 /**
  * @return \BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig|false
  */
 private function buildSiteConfig(RequestInterface $request)
 {
     return $this->configBuilder->buildForHost($request->getHost());
 }
开发者ID:bdunogier,项目名称:guzzle-site-authenticator,代码行数:7,代码来源:AuthenticatorSubscriber.php

示例11: collectRequest

 /**
  * Collect & sanitize data about a Guzzle request.
  *
  * @param RequestInterface $request Guzzle request.
  * @return array
  */
 private function collectRequest(RequestInterface $request)
 {
     $query = $request->getQuery();
     return ['headers' => $request->getHeaders(), 'method' => $request->getMethod(), 'scheme' => $request->getScheme(), 'host' => $request->getHost(), 'path' => $request->getPath(), 'query' => (string) $query, 'queryParams' => $query->toArray(), 'body' => (string) $request->getBody()];
 }
开发者ID:campru,项目名称:guzzle-bundle,代码行数:11,代码来源:GuzzleDataCollector.php


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