本文整理汇总了PHP中GuzzleHttp\Client::getFailedRequests方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getFailedRequests方法的具体用法?PHP Client::getFailedRequests怎么用?PHP Client::getFailedRequests使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Client
的用法示例。
在下文中一共展示了Client::getFailedRequests方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: collect
/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, \Exception $exception = NULL)
{
$completed = $this->middleware->getCompletedRequests();
$failed = $this->middleware->getFailedRequests();
foreach ($completed as $data) {
/** @var \GuzzleHttp\Psr7\Request $request */
$request = $data['request'];
/** @var \GuzzleHttp\Psr7\Response $response */
$response = $data['response'];
/** @var \GuzzleHttp\TransferStats $stats */
$stats = $request->stats;
$uri = $request->getUri();
$this->data['completed'][] = ['request' => ['method' => $request->getMethod(), 'uri' => ['schema' => $uri->getScheme(), 'host' => $uri->getHost(), 'port' => $uri->getPort(), 'path' => $uri->getPath(), 'query' => $uri->getQuery(), 'fragment' => $uri->getFragment()], 'headers' => $request->getHeaders(), 'protocol' => $request->getProtocolVersion(), 'request_target' => $request->getRequestTarget(), 'stats' => ['transferTime' => $stats->getTransferTime(), 'handlerStats' => $stats->getHandlerStats()]], 'response' => ['phrase' => $response->getReasonPhrase(), 'status' => $response->getStatusCode(), 'headers' => $response->getHeaders(), 'protocol' => $response->getProtocolVersion()]];
}
foreach ($failed as $data) {
/** @var \GuzzleHttp\Psr7\Request $request */
$request = $data['request'];
/** @var \GuzzleHttp\Psr7\Response $response */
$response = $data['response'];
$uri = $request->getUri();
$this->data['failed'][] = ['request' => ['method' => $request->getMethod(), 'uri' => ['schema' => $uri->getScheme(), 'host' => $uri->getHost(), 'port' => $uri->getPort(), 'path' => $uri->getPath(), 'query' => $uri->getQuery(), 'fragment' => $uri->getFragment()], 'headers' => $request->getHeaders(), 'protocol' => $request->getProtocolVersion(), 'request_target' => $request->getRequestTarget()], 'response' => ['phrase' => $response->getReasonPhrase(), 'status' => $response->getStatusCode(), 'headers' => $response->getHeaders(), 'protocol' => $response->getProtocolVersion()]];
}
}