Skip to content

Commit 2fa1c3c

Browse files
committed
Merge remote-tracking branch 'origin/2.x' into 2-to-3
2 parents 83f269f + 40a2451 commit 2fa1c3c

File tree

11 files changed

+62
-1
lines changed

11 files changed

+62
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Changelog
99

1010
* If a custom proxy client is configured on the cache manager, the `ProxyClient` class is an alias to that client, to support autowiring.
1111
* Attribute configuration now also works on single action controllers with the `__invoke` method.
12+
* New configuration option `proxy_client.*.http.request_factory` to support custom HTTP request factories for proxy clients.
1213

1314
3.1.2
1415
-----
@@ -53,6 +54,11 @@ Changelog
5354
2.x
5455
===
5556

57+
2.18.0
58+
------
59+
60+
* New configuration option `proxy_client.*.http.request_factory` to support custom HTTP request factories for proxy clients.
61+
5662
2.17.1
5763
------
5864

Resources/doc/features/invalidation.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ To refresh paths and routes, you can use ``refreshPath($path, $headers)`` and
6666

6767
If you want to add a header (such as ``Authorization``) to *all*
6868
invalidation requests, you can use a
69-
:ref:`custom HTTP client <custom HTTP client>` instead.
69+
:ref:`custom HTTP client <custom HTTP client>` or
70+
:ref:`custom HTTP request factory <custom HTTP request factory>` instead.
7071

7172
.. _invalidation configuration:
7273

Resources/doc/reference/configuration/proxy-client.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,15 @@ example to send a basic authentication header with each request, you can
400400
configure a service for the ``HttpClient`` and specify that in the
401401
``http_client`` option of any of the cache proxy clients.
402402

403+
.. _custom HTTP request factory:
404+
405+
Custom HTTP Request Factory
406+
---------------------------
407+
408+
The proxy client uses an implementation of ``Http\Message\RequestFactory`` to create HTTP requests.
409+
If you need to customize the request creation, you can configure your custom service and
410+
specify that in the ``request_factory`` option of any of the cache proxy clients.
411+
403412
Caching Proxy Configuration
404413
---------------------------
405414

src/DependencyInjection/Configuration.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,10 @@ private function getHttpDispatcherNode(): ArrayNodeDefinition
624624
->defaultNull()
625625
->info('Httplug async client service name to use for sending the requests.')
626626
->end()
627+
->scalarNode('request_factory')
628+
->defaultNull()
629+
->info('Service name of factory for PSR-7 messages.')
630+
->end()
627631
->end()
628632
;
629633

src/DependencyInjection/FOSHttpCacheExtension.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,12 @@ private function loadVarnish(ContainerBuilder $container, XmlFileLoader $loader,
427427
$container->setParameter('fos_http_cache.proxy_client.varnish.options', $options);
428428

429429
$loader->load('varnish.xml');
430+
431+
$requestFactory = isset($config['http']['request_factory'])
432+
? new Reference($config['http']['request_factory'])
433+
: null;
434+
$container->getDefinition('fos_http_cache.proxy_client.varnish')
435+
->replaceArgument(2, $requestFactory);
430436
}
431437

432438
private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, array $config): void
@@ -436,6 +442,12 @@ private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, a
436442
'purge_location' => $config['purge_location'],
437443
]);
438444
$loader->load('nginx.xml');
445+
446+
$requestFactory = isset($config['http']['request_factory'])
447+
? new Reference($config['http']['request_factory'])
448+
: null;
449+
$container->getDefinition('fos_http_cache.proxy_client.nginx')
450+
->replaceArgument(2, $requestFactory);
439451
}
440452

441453
private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader, array $config): void
@@ -462,6 +474,12 @@ private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader,
462474
$container->setParameter('fos_http_cache.proxy_client.symfony.options', $options);
463475

464476
$loader->load('symfony.xml');
477+
478+
$requestFactory = isset($config['http']['request_factory'])
479+
? new Reference($config['http']['request_factory'])
480+
: null;
481+
$container->getDefinition('fos_http_cache.proxy_client.symfony')
482+
->replaceArgument(2, $requestFactory);
465483
}
466484

467485
private function loadCloudflare(ContainerBuilder $container, XmlFileLoader $loader, array $config): void
@@ -475,6 +493,12 @@ private function loadCloudflare(ContainerBuilder $container, XmlFileLoader $load
475493
$container->setParameter('fos_http_cache.proxy_client.cloudflare.options', $options);
476494

477495
$loader->load('cloudflare.xml');
496+
497+
$requestFactory = isset($config['http']['request_factory'])
498+
? new Reference($config['http']['request_factory'])
499+
: null;
500+
$container->getDefinition('fos_http_cache.proxy_client.cloudflare')
501+
->replaceArgument(2, $requestFactory);
478502
}
479503

480504
private function loadCloudfront(ContainerBuilder $container, XmlFileLoader $loader, array $config): void
@@ -511,6 +535,12 @@ private function loadFastly(ContainerBuilder $container, XmlFileLoader $loader,
511535
$container->setParameter('fos_http_cache.proxy_client.fastly.options', $options);
512536

513537
$loader->load('fastly.xml');
538+
539+
$requestFactory = isset($config['http']['request_factory'])
540+
? new Reference($config['http']['request_factory'])
541+
: null;
542+
$container->getDefinition('fos_http_cache.proxy_client.fastly')
543+
->replaceArgument(2, $requestFactory);
514544
}
515545

516546
/**

src/Resources/config/cloudflare.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
lazy="true">
1212
<argument type="service" id="fos_http_cache.proxy_client.cloudflare.http_dispatcher"/>
1313
<argument>%fos_http_cache.proxy_client.cloudflare.options%</argument>
14+
<argument /> <!-- request factory -->
1415
</service>
1516
</services>
1617

src/Resources/config/fastly.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
lazy="true">
1212
<argument type="service" id="fos_http_cache.proxy_client.fastly.http_dispatcher"/>
1313
<argument>%fos_http_cache.proxy_client.fastly.options%</argument>
14+
<argument /> <!-- request factory -->
1415
</service>
1516
</services>
1617

src/Resources/config/nginx.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
public="true">
1111
<argument type="service" id="fos_http_cache.proxy_client.nginx.http_dispatcher"/>
1212
<argument>%fos_http_cache.proxy_client.nginx.options%</argument>
13+
<argument /> <!-- request factory -->
1314
</service>
1415
</services>
1516

src/Resources/config/symfony.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
public="true">
1111
<argument type="service" id="fos_http_cache.proxy_client.symfony.http_dispatcher"/>
1212
<argument>%fos_http_cache.proxy_client.symfony.options%</argument>
13+
<argument /> <!-- request factory -->
1314
</service>
1415
</services>
1516

src/Resources/config/varnish.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
public="true">
1111
<argument type="service" id="fos_http_cache.proxy_client.varnish.http_dispatcher"/>
1212
<argument>%fos_http_cache.proxy_client.varnish.options%</argument>
13+
<argument /> <!-- request factory -->
1314
</service>
1415
</services>
1516

0 commit comments

Comments
 (0)