bug #30612 [FrameworkBundle] fix max host connections option for XML configs (xabbuh)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[FrameworkBundle] fix max host connections option for XML configs

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Commits
-------

3378f5e9a1 fix max host connections option for XML configs
This commit is contained in:
Fabien Potencier 2019-03-20 08:26:26 +01:00
commit 83ff914b25
5 changed files with 12 additions and 5 deletions

View File

@ -486,6 +486,7 @@
<xsd:element name="default-options" type="http_client_options" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="max-host-connections" type="xsd:integer" />
</xsd:complexType>
<xsd:complexType name="fingerprint">

View File

@ -2,11 +2,13 @@
$container->loadFromExtension('framework', [
'http_client' => [
'max_host_connections' => 4,
'default_options' => [
'headers' => ['foo' => 'bar'],
],
'clients' => [
'foo' => [
'max_host_connections' => 5,
'default_options' => [
'headers' => ['bar' => 'baz'],
],

View File

@ -6,11 +6,11 @@
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<framework:http-client>
<framework:http-client max-host-connections="4">
<framework:default-options>
<framework:header name="foo">bar</framework:header>
</framework:default-options>
<framework:client name="foo">
<framework:client name="foo" max-host-connections="5">
<framework:default-options>
<framework:header name="bar">baz</framework:header>
</framework:default-options>

View File

@ -1,8 +1,10 @@
framework:
http_client:
max_host_connections: 4
default_options:
headers: {'foo': 'bar'}
clients:
foo:
max_host_connections: 5
default_options:
headers: {'bar': 'baz'}

View File

@ -1389,15 +1389,17 @@ abstract class FrameworkExtensionTest extends TestCase
{
$container = $this->createContainerFromFile('http_client_override_default_options');
$this->assertSame(['foo' => ['bar']], $container->getDefinition('http_client')->getArguments()[0]['headers']);
$this->assertSame(['bar' => ['baz'], 'foo' => ['bar']], $container->getDefinition('foo')->getArguments()[0]['headers']);
$this->assertSame(['foo' => ['bar']], $container->getDefinition('http_client')->getArgument(0)['headers']);
$this->assertSame(4, $container->getDefinition('http_client')->getArgument(1));
$this->assertSame(['bar' => ['baz'], 'foo' => ['bar']], $container->getDefinition('foo')->getArgument(0)['headers']);
$this->assertSame(5, $container->getDefinition('foo')->getArgument(1));
}
public function testHttpClientFullDefaultOptions()
{
$container = $this->createContainerFromFile('http_client_full_default_options');
$defaultOptions = $container->getDefinition('http_client')->getArguments()[0];
$defaultOptions = $container->getDefinition('http_client')->getArgument(0);
$this->assertSame('foo:bar', $defaultOptions['auth_basic']);
$this->assertSame(['foo' => 'bar', 'bar' => 'baz'], $defaultOptions['query']);