You are here

public function HttpController::aggregateResponseHeaders in JSON-RPC 2.x

Intersects all the headers in the RPC responses into a single bag.

Parameters

\Drupal\jsonrpc\Object\Response[] $rpc_responses: The RPC responses.

Return value

\Symfony\Component\HttpFoundation\HeaderBag The aggregated header bag.

1 call to HttpController::aggregateResponseHeaders()
HttpController::resolve in src/Controller/HttpController.php
Resolves an RPC request over HTTP.

File

src/Controller/HttpController.php, line 303

Class

HttpController
The main front controller.

Namespace

Drupal\jsonrpc\Controller

Code

public function aggregateResponseHeaders(array $rpc_responses) : HeaderBag {
  return array_reduce($rpc_responses, function (?HeaderBag $carry, RpcResponse $response) {
    $intersected_headers = $carry ? array_intersect_key($carry
      ->all(), $response
      ->getHeaders()
      ->all()) : $response
      ->getHeaders()
      ->all();
    return new HeaderBag($intersected_headers);
  });
}