public function create(FilesystemInterface $cache, $path)
    {
        $stream = $cache->readStream($path);

        $response = new StreamedResponse();
        $response->headers->set('Content-Type', $cache->getMimetype($path));
        $response->headers->set('Content-Length', $cache->getSize($path));
        $response->setPublic();
        $response->setMaxAge(31536000);
        $response->setExpires(date_create()->modify('+1 years'));

        if ($this->request) {
            $response->setLastModified(date_create()->setTimestamp($cache->getTimestamp($path)));
            $response->isNotModified($this->request);
        }

        $response->setCallback(function () use ($stream) {
            if (ftell($stream) !== 0) {
                rewind($stream);
            }
            fpassthru($stream);
            fclose($stream);
        });

        return $response;
    }
public function create(FilesystemInterface $cache, $path)
    {
        $stream = $cache->readStream($path);

        $response = new StreamedResponse();
        $response->headers->set('Content-Type', $cache->getMimetype($path));
        $response->headers->set('Content-Length', $cache->getSize($path));
        $response->setPublic();
        $response->setMaxAge(31536000);
        $response->setExpires(date_create()->modify('+1 years'));

        if ($this->request) {
            $response->setLastModified(date_create()->setTimestamp($cache->getTimestamp($path)));
            $response->isNotModified($this->request);
        }

        $response->setCallback(function () use ($stream) {
            if (ftell($stream) !== 0) {
                rewind($stream);
            }
            fpassthru($stream);
            fclose($stream);
        });

        return $response;
    }
public function create ( FilesystemInterface $ cache , $ path ) { $ stream = $ cache -> readStream ( $ path ) ; $ response = new StreamedResponse ( ) ; $ response -> headers -> set ( 'Content-Type' , $ cache -> getMimetype ( $ path ) ) ; $ response -> headers -> set ( 'Content-Length' , $ cache -> getSize ( $ path ) ) ; $ response -> setPublic ( ) ; $ response -> setMaxAge ( 31536000 ) ; $ response -> setExpires ( date_create ( ) -> modify ( '+1 years' ) ) ; if ( $ this -> request ) { $ response -> setLastModified ( date_create ( ) -> setTimestamp ( $ cache -> getTimestamp ( $ path ) ) ) ; $ response -> isNotModified ( $ this -> request ) ; } $ response -> setCallback ( function ( ) use ( $ stream ) { if ( ftell ( $ stream ) !== 0 ) { rewind ( $ stream ) ; } fpassthru ( $ stream ) ; fclose ( $ stream ) ; } ) ; return $ response ; }
Create the response.
@param  FilesystemInterface $cache The cache file system.
@param  string              $path  The cached file path.
@return StreamedResponse    The response object.
Create the response .