protected function HttpCache::forward

Forwards the Request to the backend and returns the Response.

Parameters

Request $request A Request instance:

Boolean $catch Whether to catch exceptions or not:

Response $entry A Response instance (the stale entry if present, null otherwise):

Return value

Response A Response instance

3 calls to HttpCache::forward()
HttpCache::fetch in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
Forwards the Request to the backend and determines whether the response should be stored.
HttpCache::pass in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
Forwards the Request to the backend without storing the Response in the cache.
HttpCache::validate in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
Validates that a cache entry is fresh.

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php, line 440

Class

HttpCache
Cache provides HTTP caching.

Namespace

Symfony\Component\HttpKernel\HttpCache

Code

protected function forward(Request $request, $catch = false, Response $entry = null) {
  if ($this->esi) {
    $this->esi
      ->addSurrogateEsiCapability($request);
  }

  // always a "master" request (as the real master request can be in cache)
  $response = $this->kernel
    ->handle($request, HttpKernelInterface::MASTER_REQUEST, $catch);

  // FIXME: we probably need to also catch exceptions if raw === true
  // we don't implement the stale-if-error on Requests, which is nonetheless part of the RFC
  if (null !== $entry && in_array($response
    ->getStatusCode(), array(
    500,
    502,
    503,
    504,
  ))) {
    if (null === ($age = $entry->headers
      ->getCacheControlDirective('stale-if-error'))) {
      $age = $this->options['stale_if_error'];
    }
    if (abs($entry
      ->getTtl()) < $age) {
      $this
        ->record($request, 'stale-if-error');
      return $entry;
    }
  }
  $this
    ->processResponseBody($request, $response);
  return $response;
}