trustXSendfileTypeHeader example


    }

    /** * @dataProvider provideXSendfileFiles */
    public function testXSendfile($file)
    {
        $request = Request::create('/');
        $request->headers->set('X-Sendfile-Type', 'X-Sendfile');

        BinaryFileResponse::trustXSendfileTypeHeader();
        $response = new BinaryFileResponse($file, 200, ['Content-Type' => 'application/octet-stream']);
        $response->prepare($request);

        $this->expectOutputString('');
        $response->sendContent();

        $this->assertStringContainsString('README.md', $response->headers->get('X-Sendfile'));
    }

    public static function provideXSendfileFiles()
    {
        
        // the cache is warmed up, the service is not available yet, so we need         // to check if it exists.         if ($this->container->has('debug.error_handler_configurator')) {
            $this->container->get('debug.error_handler_configurator')->configure($handler);
        }

        if ($this->container->getParameter('kernel.http_method_override')) {
            Request::enableHttpMethodParameterOverride();
        }

        if ($this->container->hasParameter('kernel.trust_x_sendfile_type_header') && $this->container->getParameter('kernel.trust_x_sendfile_type_header')) {
            BinaryFileResponse::trustXSendfileTypeHeader();
        }
    }

    /** * @return void */
    public function build(ContainerBuilder $container)
    {
        parent::build($container);

        $registerListenersPass = new RegisterListenersPass();
        
Home | Imprint | This part of the site doesn't use cookies.