From 010aa39f3c51f642190f695f0f0e662baa604238 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Tue, 21 Feb 2023 19:25:27 +0100 Subject: [PATCH] [FrameworkBundle] Add `framework.http_cache.skip_response_headers` option --- src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md | 1 + .../FrameworkBundle/DependencyInjection/Configuration.php | 4 ++++ .../DependencyInjection/FrameworkExtension.php | 4 ++++ .../Tests/DependencyInjection/ConfigurationTest.php | 1 + src/Symfony/Component/HttpClient/CachingHttpClient.php | 1 + 5 files changed, 11 insertions(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index f530786ac6bfa..671253a34f8c2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -15,6 +15,7 @@ CHANGELOG * Register alias for argument for workflow services with workflow name only * Configure the `ErrorHandler` on `FrameworkBundle::boot()` * Allow setting `debug.container.dump` to `false` to disable dumping the container to XML + * Add `framework.http_cache.skip_response_headers` option 6.2 --- diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 53c1526866923..24b06a79e3f4e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -263,6 +263,10 @@ private function addHttpCacheSection(ArrayNodeDefinition $rootNode): void ->performNoDeepMerging() ->scalarPrototype()->end() ->end() + ->arrayNode('skip_response_headers') + ->performNoDeepMerging() + ->scalarPrototype()->end() + ->end() ->booleanNode('allow_reload')->end() ->booleanNode('allow_revalidate')->end() ->integerNode('stale_while_revalidate')->end() diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index c726519d3d18b..529e2d7efcce5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -762,6 +762,10 @@ private function registerHttpCacheConfiguration(array $config, ContainerBuilder unset($options['private_headers']); } + if (!$options['skip_response_headers']) { + unset($options['skip_response_headers']); + } + $container->getDefinition('http_cache') ->setPublic($config['enabled']) ->replaceArgument(3, $options); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 7aa944dcdeb12..6be5ac85a10c6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -671,6 +671,7 @@ class_exists(SemaphoreStore::class) && SemaphoreStore::isSupported() ? 'semaphor 'enabled' => false, 'debug' => '%kernel.debug%', 'private_headers' => [], + 'skip_response_headers' => [], ], 'rate_limiter' => [ 'enabled' => !class_exists(FullStack::class) && class_exists(TokenBucketLimiter::class), diff --git a/src/Symfony/Component/HttpClient/CachingHttpClient.php b/src/Symfony/Component/HttpClient/CachingHttpClient.php index 05a8e6b4c6ebc..0b6e49580615e 100644 --- a/src/Symfony/Component/HttpClient/CachingHttpClient.php +++ b/src/Symfony/Component/HttpClient/CachingHttpClient.php @@ -52,6 +52,7 @@ public function __construct(HttpClientInterface $client, StoreInterface $store, unset($defaultOptions['debug']); unset($defaultOptions['default_ttl']); unset($defaultOptions['private_headers']); + unset($defaultOptions['skip_response_headers']); unset($defaultOptions['allow_reload']); unset($defaultOptions['allow_revalidate']); unset($defaultOptions['stale_while_revalidate']);