Forwards the Request to the backend and returns the Response.
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):
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;
}