Skip to content

Commit a8c4e27

Browse files
committed
Add support for configurable HTTP request factory for proxy clients
1 parent 83ed7e4 commit a8c4e27

File tree

7 files changed

+29
-0
lines changed

7 files changed

+29
-0
lines changed

src/DependencyInjection/Configuration.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,10 @@ private function getHttpDispatcherNode()
641641
->defaultNull()
642642
->info('Httplug async client service name to use for sending the requests.')
643643
->end()
644+
->scalarNode('request_factory')
645+
->defaultNull()
646+
->info('Service name of factory for PSR-7 messages.')
647+
->end()
644648
->end()
645649
;
646650

src/DependencyInjection/FOSHttpCacheExtension.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ private function loadVarnish(ContainerBuilder $container, XmlFileLoader $loader,
430430
$container->setParameter('fos_http_cache.proxy_client.varnish.options', $options);
431431

432432
$loader->load('varnish.xml');
433+
434+
$requestFactory = $config['http']['request_factory'] ? new Reference($config['http']['request_factory']) : null;
435+
$container->getDefinition('fos_http_cache.proxy_client.varnish')
436+
->replaceArgument(2, $requestFactory);
433437
}
434438

435439
private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, array $config)
@@ -439,6 +443,10 @@ private function loadNginx(ContainerBuilder $container, XmlFileLoader $loader, a
439443
'purge_location' => $config['purge_location'],
440444
]);
441445
$loader->load('nginx.xml');
446+
447+
$requestFactory = $config['http']['request_factory'] ? new Reference($config['http']['request_factory']) : null;
448+
$container->getDefinition('fos_http_cache.proxy_client.nginx')
449+
->replaceArgument(2, $requestFactory);
442450
}
443451

444452
private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader, array $config)
@@ -465,6 +473,10 @@ private function loadSymfony(ContainerBuilder $container, XmlFileLoader $loader,
465473
$container->setParameter('fos_http_cache.proxy_client.symfony.options', $options);
466474

467475
$loader->load('symfony.xml');
476+
477+
$requestFactory = $config['http']['request_factory'] ? new Reference($config['http']['request_factory']) : null;
478+
$container->getDefinition('fos_http_cache.proxy_client.symfony')
479+
->replaceArgument(2, $requestFactory);
468480
}
469481

470482
private function loadCloudflare(ContainerBuilder $container, XmlFileLoader $loader, array $config)
@@ -478,6 +490,10 @@ private function loadCloudflare(ContainerBuilder $container, XmlFileLoader $load
478490
$container->setParameter('fos_http_cache.proxy_client.cloudflare.options', $options);
479491

480492
$loader->load('cloudflare.xml');
493+
494+
$requestFactory = $config['http']['request_factory'] ? new Reference($config['http']['request_factory']) : null;
495+
$container->getDefinition('fos_http_cache.proxy_client.cloudflare')
496+
->replaceArgument(2, $requestFactory);
481497
}
482498

483499
private function loadCloudfront(ContainerBuilder $container, XmlFileLoader $loader, array $config)
@@ -514,6 +530,10 @@ private function loadFastly(ContainerBuilder $container, XmlFileLoader $loader,
514530
$container->setParameter('fos_http_cache.proxy_client.fastly.options', $options);
515531

516532
$loader->load('fastly.xml');
533+
534+
$requestFactory = $config['http']['request_factory'] ? new Reference($config['http']['request_factory']) : null;
535+
$container->getDefinition('fos_http_cache.proxy_client.fastly')
536+
->replaceArgument(2, $requestFactory);
517537
}
518538

519539
/**

src/Resources/config/cloudflare.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.cloudflare.http_dispatcher"/>
1212
<argument>%fos_http_cache.proxy_client.cloudflare.options%</argument>
13+
<argument /> <!-- request factory -->
1314
</service>
1415
</services>
1516

src/Resources/config/fastly.xml

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

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)