Zend\Expressive\TemplatedErrorHandler::handlePotentialSuccess PHP Method

handlePotentialSuccess() private method

Non-error conditions mean either all middleware called $next(), and we have a complete response, or no middleware was able to handle the request. This method determines which occurred, returning the response in the first instance, and returning a 404 response in the second.
private handlePotentialSuccess ( Psr\Http\Message\RequestInterface $request, Psr\Http\Message\ResponseInterface $response ) : Psr\Http\Message\ResponseInterface
$request Psr\Http\Message\RequestInterface
$response Psr\Http\Message\ResponseInterface
return Psr\Http\Message\ResponseInterface
    private function handlePotentialSuccess(Request $request, Response $response)
    {
        if (!$this->originalResponse) {
            // No original response detected; decide whether we have a
            // response to return
            return $this->marshalReceivedResponse($request, $response);
        }
        $originalResponse = $this->originalResponse;
        $decoratedResponse = $request->getAttribute('originalResponse', $response);
        if ($originalResponse !== $response && $originalResponse !== $decoratedResponse) {
            // Response does not match either the original response or the
            // decorated response; return it verbatim.
            return $response;
        }
        if (($originalResponse === $response || $decoratedResponse === $response) && $this->bodySize !== $response->getBody()->getSize()) {
            // Response matches either the original response or the
            // decorated response; but the body size has changed; return it
            // verbatim.
            return $response;
        }
        return $this->create404($request, $response);
    }