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


PHP Response::getLocation方法代码示例

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


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

示例1: prepareRedirection

 protected function prepareRedirection(RequestInterface $original, RequestInterface $request, Response $response)
 {
     $params = $original->getParams();
     $current = $params[self::REDIRECT_COUNT] + 1;
     $params[self::REDIRECT_COUNT] = $current;
     $max = isset($params[self::MAX_REDIRECTS]) ? $params[self::MAX_REDIRECTS] : $this->defaultMaxRedirects;
     if ($current > $max) {
         $this->throwTooManyRedirectsException($original, $max);
         return false;
     } else {
         return $this->createRedirectRequest($request, $response->getStatusCode(), trim($response->getLocation()), $original);
     }
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:13,代码来源:RedirectPlugin.php

示例2: prepareRedirection

 /**
  * Prepare the request for redirection and enforce the maximum number of allowed redirects per client
  *
  * @param RequestInterface $original  Original request
  * @param RequestInterface $request   Request to prepare and validate
  * @param Response         $response  The current response
  *
  * @return RequestInterface
  */
 protected function prepareRedirection(RequestInterface $original, RequestInterface $request, Response $response)
 {
     $params = $original->getParams();
     // This is a new redirect, so increment the redirect counter
     $current = $params[self::REDIRECT_COUNT] + 1;
     $params[self::REDIRECT_COUNT] = $current;
     // Use a provided maximum value or default to a max redirect count of 5
     $max = isset($params[self::MAX_REDIRECTS]) ? $params[self::MAX_REDIRECTS] : $this->defaultMaxRedirects;
     // Throw an exception if the redirect count is exceeded
     if ($current > $max) {
         $this->throwTooManyRedirectsException($original, $max);
         return false;
     } else {
         // Create a redirect request based on the redirect rules set on the request
         return $this->createRedirectRequest($request, $response->getStatusCode(), trim($response->getLocation()), $original);
     }
 }
开发者ID:mickdane,项目名称:zidisha,代码行数:26,代码来源:RedirectPlugin.php

示例3: getResponseLocation

 /**
  * 
  * @param \Guzzle\Http\Message\Response $response
  * @return string
  */
 private function getResponseLocation(\Guzzle\Http\Message\Response $response)
 {
     $absoluteUrlDeriver = new \webignition\AbsoluteUrlDeriver\AbsoluteUrlDeriver($response->getLocation(), $this->currentUrl);
     return (string) $absoluteUrlDeriver->getAbsoluteUrl();
 }
开发者ID:webignition,项目名称:http-redirect-loop-detector,代码行数:10,代码来源:HttpRedirectLoopDetector.php


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