You are here

protected function DebugCallGraphTrait::debugInfoForResponse in Varnish purger 8.2

Extract debug information from a response.

Parameters

\Psr\Http\Message\ResponseInterface $r: The HTTP response object.

\GuzzleHttp\Exception\RequestException $e: Optional exception in case of failures.

Return value

string[]

2 calls to DebugCallGraphTrait::debugInfoForResponse()
DebugCallGraphTrait::logFailedRequest in src/DebugCallGraphTrait.php
Write an error to the log for a failed request.
ZeroConfigPurger::getResultsConcurrently in src/Plugin/Purge/Purger/ZeroConfigPurger.php
Concurrently execute the given requests.

File

src/DebugCallGraphTrait.php, line 105

Class

DebugCallGraphTrait

Namespace

Drupal\varnish_purger

Code

protected function debugInfoForResponse(ResponseInterface $r, RequestException $e = NULL) {
  $info = [];
  $info['rsp http'] = $r
    ->getProtocolVersion();
  $info['rsp status'] = $r
    ->getStatusCode();
  $info['rsp reason'] = $r
    ->getReasonPhrase();
  if (!is_null($e)) {
    $info['rsp summary'] = json_encode($e
      ->getResponseBodySummary($r));
  }
  $info['rsp headers'] = [];
  foreach ($r
    ->getHeaders() as $h => $v) {
    $info['rsp headers'][] = $h . ': ' . $r
      ->getHeaderLine($h);
  }
  return $info;
}