本文整理匯總了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);
}
}
示例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);
}
}
示例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();
}