本文整理汇总了PHP中Goutte\Client::doRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::doRequest方法的具体用法?PHP Client::doRequest怎么用?PHP Client::doRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Goutte\Client
的用法示例。
在下文中一共展示了Client::doRequest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doRequest
public function doRequest($request)
{
$uri = $request->getUri();
if ($this->walker->isUrlToCheck($uri, "")) {
$response = parent::doRequest($request);
$statusCode = $response->getStatus();
$this->lastUri = $uri;
$this->lastStatus = $statusCode;
$this->walker->storage->add("stats", array("URL" => $uri, "STATUS" => $statusCode, "CALLED IN" => $this->lastReferer));
} else {
$headers[] = "";
$statusCode = $this->walker->storage->find("stats", $uri)[1];
$response = new Response("", $statusCode, $headers);
}
$this->walker->urlsVisited[] = $uri;
return $response;
}
示例2: doRequest
/**
* Cache decorator and extend timeout
* @param Request $request
*/
protected function doRequest($request)
{
if ($cache = $this->getRequestCache($request)) {
return $cache;
}
$attempt = 0;
while ($attempt < static::ATTEMPTS) {
try {
$result = parent::doRequest($request);
if ($this->useCache) {
$this->setRequestCache($request, $result);
}
return $result;
} catch (\Exception $e) {
$attempt++;
}
}
throw new \Exception('20 request attempts failed.');
}