当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::getFailedRequests方法代码示例

本文整理汇总了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()]];
     }
 }
开发者ID:penguinclub,项目名称:penguinweb_drupal8,代码行数:26,代码来源:HttpDataCollector.php


注:本文中的GuzzleHttp\Client::getFailedRequests方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。