function EntityResourceTestBase::normalizeHeadersForGetHeadComparison

Normalizes response headers before HEAD vs GET equality assertion.

Authentication providers that don't persist a session between requests (e.g. basic_auth) cause a fresh CSRF token seed to be generated for each request, so HEAD and GET produce different token values in any URL that carries `?token=`. The URL structure and link relations are still the same. Override this hook to neutralize such legitimately-varying values for the comparison.

Parameters

array $headers: Response headers as returned by Guzzle.

Return value

array The headers, with provider-specific normalization applied.

1 call to EntityResourceTestBase::normalizeHeadersForGetHeadComparison()
EntityResourceTestBase::doTestGet in core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
Tests a GET request for an entity, plus edge cases to ensure good DX.

File

core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php, line 433

Class

EntityResourceTestBase
Defines a base class for testing all entity resources.

Namespace

Drupal\Tests\rest\Functional\EntityResource

Code

protected function normalizeHeadersForGetHeadComparison(array $headers) : array {
  return $headers;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.