Fix HTTP client config handling
This commit is contained in:
parent
6f29d8d508
commit
963d0cce86
@ -1402,7 +1402,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
if (!\is_array($config)) {
|
if (!\is_array($config)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (!isset($config['host'])) {
|
if (!isset($config['host'], $config['value']) || \count($config) > 2) {
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1511,7 +1511,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
if (!\is_array($config)) {
|
if (!\is_array($config)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (!isset($config['key'])) {
|
if (!isset($config['key'], $config['value']) || \count($config) > 2) {
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1541,7 +1541,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
if (!\is_array($config)) {
|
if (!\is_array($config)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (!isset($config['host'])) {
|
if (!isset($config['host'], $config['value']) || \count($config) > 2) {
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$container->loadFromExtension('framework', [
|
||||||
|
'http_client' => [
|
||||||
|
'default_options' => [
|
||||||
|
'resolve' => [
|
||||||
|
'host' => '127.0.0.1',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'scoped_clients' => [
|
||||||
|
'foo' => [
|
||||||
|
'base_uri' => 'http://example.com',
|
||||||
|
'query' => [
|
||||||
|
'key' => 'foo',
|
||||||
|
],
|
||||||
|
'resolve' => [
|
||||||
|
'host' => '127.0.0.1',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]);
|
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<container xmlns="http://symfony.com/schema/dic/services"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:framework="http://symfony.com/schema/dic/symfony"
|
||||||
|
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
|
||||||
|
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||||
|
|
||||||
|
<framework:config>
|
||||||
|
<framework:http-client>
|
||||||
|
<framework:default-options>
|
||||||
|
<framework:resolve host="host">127.0.0.1</framework:resolve>
|
||||||
|
</framework:default-options>
|
||||||
|
<framework:scoped-client name="foo" base-uri="http://example.com">
|
||||||
|
<framework:query key="key">foo</framework:query>
|
||||||
|
<framework:resolve host="host">127.0.0.1</framework:resolve>
|
||||||
|
</framework:scoped-client>
|
||||||
|
</framework:http-client>
|
||||||
|
</framework:config>
|
||||||
|
</container>
|
@ -0,0 +1,12 @@
|
|||||||
|
framework:
|
||||||
|
http_client:
|
||||||
|
default_options:
|
||||||
|
resolve:
|
||||||
|
host: 127.0.0.1
|
||||||
|
scoped_clients:
|
||||||
|
foo:
|
||||||
|
base_uri: http://example.com
|
||||||
|
query:
|
||||||
|
key: foo
|
||||||
|
resolve:
|
||||||
|
host: 127.0.0.1
|
@ -1559,6 +1559,21 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
$this->assertSame($expected, $container->getDefinition('foo')->getArgument(2));
|
$this->assertSame($expected, $container->getDefinition('foo')->getArgument(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testHttpClientWithQueryParameterKey()
|
||||||
|
{
|
||||||
|
$container = $this->createContainerFromFile('http_client_xml_key');
|
||||||
|
|
||||||
|
$expected = [
|
||||||
|
'key' => 'foo',
|
||||||
|
];
|
||||||
|
$this->assertSame($expected, $container->getDefinition('foo')->getArgument(2)['query']);
|
||||||
|
|
||||||
|
$expected = [
|
||||||
|
'host' => '127.0.0.1',
|
||||||
|
];
|
||||||
|
$this->assertSame($expected, $container->getDefinition('foo')->getArgument(2)['resolve']);
|
||||||
|
}
|
||||||
|
|
||||||
public function testHttpClientFullDefaultOptions()
|
public function testHttpClientFullDefaultOptions()
|
||||||
{
|
{
|
||||||
$container = $this->createContainerFromFile('http_client_full_default_options');
|
$container = $this->createContainerFromFile('http_client_full_default_options');
|
||||||
|
Reference in New Issue
Block a user