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


PHP RequestInterface::getScheme方法代码示例

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


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

示例1: createRingRequest

 /**
  * Creates a Ring request from a request object.
  *
  * This function does not hook up the "then" and "progress" events that
  * would be required for actually sending a Guzzle request through a
  * RingPHP handler.
  *
  * @param RequestInterface $request Request to convert.
  *
  * @return array Converted Guzzle Ring request.
  */
 public static function createRingRequest(RequestInterface $request)
 {
     $options = $request->getConfig()->toArray();
     $url = $request->getUrl();
     // No need to calculate the query string twice (in URL and query).
     $qs = ($pos = strpos($url, '?')) ? substr($url, $pos + 1) : null;
     return ['scheme' => $request->getScheme(), 'http_method' => $request->getMethod(), 'url' => $url, 'uri' => $request->getPath(), 'headers' => $request->getHeaders(), 'body' => $request->getBody(), 'version' => $request->getProtocolVersion(), 'client' => $options, 'query_string' => $qs, 'future' => isset($options['future']) ? $options['future'] : false];
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:19,代码来源:RingBridge.php

示例2: add_proxy

 private function add_proxy(RequestInterface $request, &$options, $value, &$params)
 {
     if (!is_array($value)) {
         $options['http']['proxy'] = $value;
         $options['http']['request_fulluri'] = true;
     } else {
         $scheme = $request->getScheme();
         if (isset($value[$scheme])) {
             $options['http']['proxy'] = $value[$scheme];
             $options['http']['request_fulluri'] = true;
         }
     }
 }
开发者ID:ChenOhayon,项目名称:sitepoint_codes,代码行数:13,代码来源:StreamAdapter.php

示例3: add_proxy

 private function add_proxy(RequestInterface $request, RequestMediator $mediator, &$options, $value)
 {
     if (!is_array($value)) {
         $options[CURLOPT_PROXY] = $value;
     } else {
         $scheme = $request->getScheme();
         if (isset($value[$scheme])) {
             $options[CURLOPT_PROXY] = $value[$scheme];
         }
     }
 }
开发者ID:ChenOhayon,项目名称:sitepoint_codes,代码行数:11,代码来源:CurlFactory.php

示例4: 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

示例5: 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

示例6: createRedirectRequest

 /**
  * Create a redirect request for a specific request object
  *
  * Takes into account strict RFC compliant redirection (e.g. redirect POST
  * with POST) vs doing what most clients do (e.g. redirect POST with GET).
  *
  * @param RequestInterface  $request
  * @param ResponseInterface $response
  *
  * @return RequestInterface Returns a new redirect request
  * @throws CouldNotRewindStreamException If the body cannot be rewound.
  */
 private function createRedirectRequest(RequestInterface $request, ResponseInterface $response)
 {
     $config = $request->getConfig();
     // Use a GET request if this is an entity enclosing request and we are
     // not forcing RFC compliance, but rather emulating what all browsers
     // would do. Be sure to disable redirects on the clone.
     $redirectRequest = clone $request;
     $redirectRequest->getEmitter()->detach($this);
     $statusCode = $response->getStatusCode();
     if ($statusCode == 303 || $statusCode <= 302 && $request->getBody() && !$config->getPath('redirect/strict')) {
         $redirectRequest->setMethod('GET');
         $redirectRequest->setBody(null);
     }
     $this->setRedirectUrl($redirectRequest, $response);
     $this->rewindEntityBody($redirectRequest);
     // Add the Referer header if it is told to do so and only
     // add the header if we are not redirecting from https to http.
     if ($config->getPath('redirect/referer') && ($redirectRequest->getScheme() == 'https' || $redirectRequest->getScheme() == $request->getScheme())) {
         $url = Url::fromString($request->getUrl());
         $url->setUsername(null)->setPassword(null);
         $redirectRequest->setHeader('Referer', (string) $url);
     }
     return $redirectRequest;
 }
开发者ID:hilmysyarif,项目名称:sic,代码行数:36,代码来源:Redirect.php

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