當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。