Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdaad2ae

Browse files
Add support to set trustxsendfilehader over framework configuration
1 parent791ee7d commitdaad2ae

File tree

6 files changed

+19
-0
lines changed

6 files changed

+19
-0
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ public function getConfigTreeBuilder(): TreeBuilder
8181
->info("Set true to enable support for the '_method' request parameter to determine the intended HTTP method on POST requests. Note: When using the HttpCache, you need to call the method in your front controller instead")
8282
->defaultTrue()
8383
->end()
84+
->scalarNode('trust_x_sendfile_type_header')
85+
->info("Set true to enable support for xsendfile in binary file responses.")
86+
->defaultFalse()
87+
->end()
8488
->scalarNode('ide')->defaultValue('%env(default::SYMFONY_IDE)%')->end()
8589
->booleanNode('test')->end()
8690
->scalarNode('default_locale')->defaultValue('en')->end()

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ public function load(array $configs, ContainerBuilder $container)
327327
}
328328

329329
$container->setParameter('kernel.http_method_override',$config['http_method_override']);
330+
$container->setParameter('kernel.trust_x_sendfile_type_header',$config['trust_x_sendfile_type_header']);
330331
$container->setParameter('kernel.trusted_hosts',$config['trusted_hosts']);
331332
$container->setParameter('kernel.default_locale',$config['default_locale']);
332333
$container->setParameter('kernel.enabled_locales',$config['enabled_locales']);

‎src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
useSymfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
4545
useSymfony\Component\Form\DependencyInjection\FormPass;
4646
useSymfony\Component\HttpClient\DependencyInjection\HttpClientPass;
47+
useSymfony\Component\HttpFoundation\BinaryFileResponse;
4748
useSymfony\Component\HttpFoundation\Request;
4849
useSymfony\Component\HttpKernel\Bundle\Bundle;
4950
useSymfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass;
@@ -94,6 +95,10 @@ public function boot()
9495
if ($this->container->getParameter('kernel.http_method_override')) {
9596
Request::enableHttpMethodParameterOverride();
9697
}
98+
99+
if ($this->container->getParameter('kernel.trust_x_sendfile_type_header')) {
100+
BinaryFileResponse::trustXSendfileTypeHeader();
101+
}
97102
}
98103

99104
publicfunctionbuild(ContainerBuilder$container)

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ protected static function getBundleDefaultConfig()
369369
{
370370
return [
371371
'http_method_override' =>true,
372+
'trust_x_sendfile_type_header' =>false,
372373
'ide' =>'%env(default::SYMFONY_IDE)%',
373374
'default_locale' =>'en',
374375
'enabled_locales' => [],

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ framework:
77
csrf_protection:
88
field_name:_csrf
99
http_method_override:false
10+
trust_x_sendfile_type_header:true
1011
esi:
1112
enabled:true
1213
ssi:

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ public function testHttpMethodOverride()
174174
$this->assertFalse($container->getParameter('kernel.http_method_override'));
175175
}
176176

177+
publicfunctiontestTrustXSendfileTypeHeader()
178+
{
179+
$container =$this->createContainerFromFile('full');
180+
181+
$this->assertTrue($container->getParameter('kernel.trust_x_sendfile_type_header'));
182+
}
183+
177184
publicfunctiontestEsi()
178185
{
179186
$container =$this->createContainerFromFile('full');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp