You are here

protected function SecKitTestCaseTest::secKitRequestHeader in Security Kit 2.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/SecKitTestCaseTest.php \Drupal\Tests\seckit\Functional\SecKitTestCaseTest::secKitRequestHeader()

Adds an origin to requests if $this->originHeader is set.

Return value

\Closure A callback that adds an origin header to the request if necessary.

1 call to SecKitTestCaseTest::secKitRequestHeader()
SecKitTestCaseTest::setUp in tests/src/Functional/SecKitTestCaseTest.php

File

tests/src/Functional/SecKitTestCaseTest.php, line 624

Class

SecKitTestCaseTest
Functional tests for Security Kit.

Namespace

Drupal\Tests\seckit\Functional

Code

protected function secKitRequestHeader() {
  return function (callable $handler) {
    return function (RequestInterface $request, array $options) use ($handler) {
      if ($this->originHeader) {
        $request = $request
          ->withHeader('origin', $this->originHeader);
      }
      return $handler($request, $options);
    };
  };
}