master

laravel/framework

Last updated at: 29/12/2023 09:23

CheckResponseForModifications.php

TLDR

This file contains the CheckResponseForModifications class, which is responsible for checking if the response from a request has been modified.

Classes

CheckResponseForModifications

The CheckResponseForModifications class is a middleware class in the Illuminate\Http\Middleware namespace. It has one method, handle(), which is used to handle an incoming request and check if the response has been modified. It takes two parameters - the request object and a closure object. The closure object represents the next middleware in the pipeline. The handle() method returns the response object after checking for modifications.

<?php

namespace Illuminate\Http\Middleware;

use Closure;
use Symfony\Component\HttpFoundation\Response;

class CheckResponseForModifications
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $response = $next($request);

        if ($response instanceof Response) {
            $response->isNotModified($request);
        }

        return $response;
    }
}