本文整理汇总了PHP中GuzzleHttp\Client::getCompletedRequests方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getCompletedRequests方法的具体用法?PHP Client::getCompletedRequests怎么用?PHP Client::getCompletedRequests使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Client
的用法示例。
在下文中一共展示了Client::getCompletedRequests方法的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()]];
}
}