work with attributes for xml config
This commit is contained in:
parent
0023a71260
commit
f2d2cf3021
@ -22,6 +22,7 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
|||||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||||
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
use Symfony\Component\DependencyInjection\Exception\LogicException;
|
||||||
use Symfony\Component\Form\Form;
|
use Symfony\Component\Form\Form;
|
||||||
|
use Symfony\Component\HttpClient\HttpClient;
|
||||||
use Symfony\Component\HttpFoundation\Cookie;
|
use Symfony\Component\HttpFoundation\Cookie;
|
||||||
use Symfony\Component\Lock\Lock;
|
use Symfony\Component\Lock\Lock;
|
||||||
use Symfony\Component\Lock\Store\SemaphoreStore;
|
use Symfony\Component\Lock\Store\SemaphoreStore;
|
||||||
@ -1179,7 +1180,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->children()
|
->children()
|
||||||
->arrayNode('http_client')
|
->arrayNode('http_client')
|
||||||
->info('HTTP Client configuration')
|
->info('HTTP Client configuration')
|
||||||
->canBeEnabled()
|
->{!class_exists(FullStack::class) && class_exists(HttpClient::class) ? 'canBeDisabled' : 'canBeEnabled'}()
|
||||||
->fixXmlConfig('client')
|
->fixXmlConfig('client')
|
||||||
->children();
|
->children();
|
||||||
|
|
||||||
@ -1213,12 +1214,27 @@ class Configuration implements ConfigurationInterface
|
|||||||
->arrayNode('default_options')
|
->arrayNode('default_options')
|
||||||
->fixXmlConfig('header')
|
->fixXmlConfig('header')
|
||||||
->children()
|
->children()
|
||||||
->scalarNode('auth')
|
->scalarNode('auth_basic')
|
||||||
->info('An HTTP Basic authentication "username:password".')
|
->info('An HTTP Basic authentication "username:password".')
|
||||||
->end()
|
->end()
|
||||||
|
->scalarNode('auth_bearer')
|
||||||
|
->info('A token enabling HTTP Bearer authorization.')
|
||||||
|
->end()
|
||||||
->arrayNode('query')
|
->arrayNode('query')
|
||||||
->info('Associative array of query string values merged with URL parameters.')
|
->info('Associative array of query string values merged with URL parameters.')
|
||||||
->useAttributeAsKey('key')
|
->useAttributeAsKey('key')
|
||||||
|
->beforeNormalization()
|
||||||
|
->always(function ($config) {
|
||||||
|
if (!\is_array($config)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (!isset($config['key'])) {
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$config['key'] => $config['value']];
|
||||||
|
})
|
||||||
|
->end()
|
||||||
->normalizeKeys(false)
|
->normalizeKeys(false)
|
||||||
->scalarPrototype()->end()
|
->scalarPrototype()->end()
|
||||||
->end()
|
->end()
|
||||||
@ -1237,12 +1253,21 @@ class Configuration implements ConfigurationInterface
|
|||||||
->scalarNode('base_uri')
|
->scalarNode('base_uri')
|
||||||
->info('The URI to resolve relative URLs, following rules in RFC 3986, section 2.')
|
->info('The URI to resolve relative URLs, following rules in RFC 3986, section 2.')
|
||||||
->end()
|
->end()
|
||||||
->booleanNode('buffer')
|
|
||||||
->info('Indicates if the response should be buffered or not.')
|
|
||||||
->end()
|
|
||||||
->arrayNode('resolve')
|
->arrayNode('resolve')
|
||||||
->info('Associative array: domain => IP.')
|
->info('Associative array: domain => IP.')
|
||||||
->useAttributeAsKey('host')
|
->useAttributeAsKey('host')
|
||||||
|
->beforeNormalization()
|
||||||
|
->always(function ($config) {
|
||||||
|
if (!\is_array($config)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (!isset($config['host'])) {
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$config['host'] => $config['value']];
|
||||||
|
})
|
||||||
|
->end()
|
||||||
->normalizeKeys(false)
|
->normalizeKeys(false)
|
||||||
->scalarPrototype()->end()
|
->scalarPrototype()->end()
|
||||||
->end()
|
->end()
|
||||||
@ -1284,9 +1309,12 @@ class Configuration implements ConfigurationInterface
|
|||||||
->end()
|
->end()
|
||||||
->arrayNode('peer_fingerprint')
|
->arrayNode('peer_fingerprint')
|
||||||
->info('Associative array: hashing algorithm => hash(es).')
|
->info('Associative array: hashing algorithm => hash(es).')
|
||||||
->useAttributeAsKey('algo')
|
|
||||||
->normalizeKeys(false)
|
->normalizeKeys(false)
|
||||||
->variablePrototype()->end()
|
->children()
|
||||||
|
->variableNode('sha1')->end()
|
||||||
|
->variableNode('pin-sha256')->end()
|
||||||
|
->variableNode('md5')->end()
|
||||||
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
|
@ -1771,9 +1771,16 @@ class FrameworkExtension extends Extension
|
|||||||
public function merge(array $options, array $defaultOptions)
|
public function merge(array $options, array $defaultOptions)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
[, $options] = $this->prepareRequest(null, null, $options, $defaultOptions);
|
[, $mergedOptions] = $this->prepareRequest(null, null, $options, $defaultOptions);
|
||||||
|
|
||||||
return $options;
|
foreach ($mergedOptions as $k => $v) {
|
||||||
|
if (!isset($options[$k]) && !isset($defaultOptions[$k])) {
|
||||||
|
// Remove options added by prepareRequest()
|
||||||
|
unset($mergedOptions[$k]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $mergedOptions;
|
||||||
} catch (TransportExceptionInterface $e) {
|
} catch (TransportExceptionInterface $e) {
|
||||||
throw new InvalidArgumentException($e->getMessage(), 0, $e);
|
throw new InvalidArgumentException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
@ -1783,6 +1790,11 @@ class FrameworkExtension extends Extension
|
|||||||
$defaultOptions = $merger->merge($config['default_options'] ?? [], []);
|
$defaultOptions = $merger->merge($config['default_options'] ?? [], []);
|
||||||
$container->getDefinition('http_client')->setArguments([$defaultOptions, $config['max_host_connections'] ?? 6]);
|
$container->getDefinition('http_client')->setArguments([$defaultOptions, $config['max_host_connections'] ?? 6]);
|
||||||
|
|
||||||
|
if (!$hasPsr18 = interface_exists(ClientInterface::class)) {
|
||||||
|
$container->removeDefinition('psr18.http_client');
|
||||||
|
$container->removeAlias(ClientInterface::class);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($config['clients'] as $name => $clientConfig) {
|
foreach ($config['clients'] as $name => $clientConfig) {
|
||||||
$options = $merger->merge($clientConfig['default_options'] ?? [], $defaultOptions);
|
$options = $merger->merge($clientConfig['default_options'] ?? [], $defaultOptions);
|
||||||
|
|
||||||
@ -1790,12 +1802,15 @@ class FrameworkExtension extends Extension
|
|||||||
->setFactory([HttpClient::class, 'create'])
|
->setFactory([HttpClient::class, 'create'])
|
||||||
->setArguments([$options, $clientConfig['max_host_connections'] ?? $config['max_host_connections'] ?? 6]);
|
->setArguments([$options, $clientConfig['max_host_connections'] ?? $config['max_host_connections'] ?? 6]);
|
||||||
|
|
||||||
$container->register('psr18.'.$name, Psr18Client::class)
|
|
||||||
->setAutowired(true)
|
|
||||||
->setArguments([new Reference($name)]);
|
|
||||||
|
|
||||||
$container->registerAliasForArgument($name, HttpClientInterface::class);
|
$container->registerAliasForArgument($name, HttpClientInterface::class);
|
||||||
$container->registerAliasForArgument('psr18.'.$name, ClientInterface::class, $name);
|
|
||||||
|
if ($hasPsr18) {
|
||||||
|
$container->register('psr18.'.$name, Psr18Client::class)
|
||||||
|
->setAutowired(true)
|
||||||
|
->setArguments([new Reference($name)]);
|
||||||
|
|
||||||
|
$container->registerAliasForArgument('psr18.'.$name, ClientInterface::class, $name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
<xsd:element name="php-errors" type="php-errors" minOccurs="0" maxOccurs="1" />
|
<xsd:element name="php-errors" type="php-errors" minOccurs="0" maxOccurs="1" />
|
||||||
<xsd:element name="lock" type="lock" minOccurs="0" maxOccurs="1" />
|
<xsd:element name="lock" type="lock" minOccurs="0" maxOccurs="1" />
|
||||||
<xsd:element name="messenger" type="messenger" minOccurs="0" maxOccurs="1" />
|
<xsd:element name="messenger" type="messenger" minOccurs="0" maxOccurs="1" />
|
||||||
<xsd:element name="http_client" type="http_client" minOccurs="0" maxOccurs="1" />
|
<xsd:element name="http-client" type="http_client" minOccurs="0" maxOccurs="1" />
|
||||||
</xsd:choice>
|
</xsd:choice>
|
||||||
|
|
||||||
<xsd:attribute name="http-method-override" type="xsd:boolean" />
|
<xsd:attribute name="http-method-override" type="xsd:boolean" />
|
||||||
@ -448,61 +448,63 @@
|
|||||||
|
|
||||||
<xsd:complexType name="http_client">
|
<xsd:complexType name="http_client">
|
||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
<xsd:element name="max_host_connections" type="xsd:integer" minOccurs="0" />
|
<xsd:element name="default-options" type="http_client_options" minOccurs="0" />
|
||||||
<xsd:element name="default_options" type="http_client_options" minOccurs="0" />
|
|
||||||
<xsd:element name="client" type="http_client_client" minOccurs="0" maxOccurs="unbounded" />
|
<xsd:element name="client" type="http_client_client" minOccurs="0" maxOccurs="unbounded" />
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
<xsd:attribute name="enabled" type="xsd:boolean" />
|
<xsd:attribute name="enabled" type="xsd:boolean" />
|
||||||
|
<xsd:attribute name="max-host-connections" type="xsd:integer" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="http_client_options">
|
<xsd:complexType name="http_client_options" mixed="true">
|
||||||
<xsd:sequence>
|
<xsd:choice maxOccurs="unbounded">
|
||||||
<xsd:element name="auth" type="xsd:string" minOccurs="0" />
|
<xsd:element name="query" type="http_query" minOccurs="0" maxOccurs="unbounded" />
|
||||||
<xsd:element name="query" type="http_query" minOccurs="0" />
|
<xsd:element name="resolve" type="http_resolve" minOccurs="0" maxOccurs="unbounded" />
|
||||||
<xsd:element name="headers" type="http_headers" minOccurs="0" />
|
<xsd:element name="header" type="http_header" minOccurs="0" maxOccurs="unbounded" />
|
||||||
<xsd:element name="max_redirects" type="xsd:integer" minOccurs="0" />
|
<xsd:element name="peer-fingerprint" type="fingerprint" minOccurs="0" maxOccurs="unbounded" />
|
||||||
<xsd:element name="http_version" type="xsd:string" minOccurs="0" />
|
</xsd:choice>
|
||||||
<xsd:element name="base_uri" type="xsd:string" minOccurs="0" />
|
<xsd:attribute name="proxy" type="xsd:string" />
|
||||||
<xsd:element name="buffer" type="xsd:boolean" minOccurs="0" />
|
<xsd:attribute name="timeout" type="xsd:float" />
|
||||||
<xsd:element name="resolve" type="metadata" minOccurs="0" maxOccurs="unbounded" />
|
<xsd:attribute name="bindto" type="xsd:string" />
|
||||||
<xsd:element name="proxy" type="xsd:string" minOccurs="0" />
|
<xsd:attribute name="verify-peer" type="xsd:boolean" />
|
||||||
<xsd:element name="no_proxy" type="xsd:string" minOccurs="0" />
|
<xsd:attribute name="auth-basic" type="xsd:string" />
|
||||||
<xsd:element name="timeout" type="xsd:float" minOccurs="0" />
|
<xsd:attribute name="auth-bearer" type="xsd:string" />
|
||||||
<xsd:element name="bindto" type="xsd:string" minOccurs="0" />
|
<xsd:attribute name="max-redirects" type="xsd:integer" />
|
||||||
<xsd:element name="verify_peer" type="xsd:boolean" minOccurs="0" />
|
<xsd:attribute name="http-version" type="xsd:string" />
|
||||||
<xsd:element name="verify_host" type="xsd:boolean" minOccurs="0" />
|
<xsd:attribute name="base-uri" type="xsd:string" />
|
||||||
<xsd:element name="cafile" type="xsd:string" minOccurs="0" />
|
<xsd:attribute name="no-proxy" type="xsd:string" />
|
||||||
<xsd:element name="capath" type="xsd:string" minOccurs="0" />
|
<xsd:attribute name="verify-host" type="xsd:boolean" />
|
||||||
<xsd:element name="local_cert" type="xsd:string" minOccurs="0" />
|
<xsd:attribute name="cafile" type="xsd:string" />
|
||||||
<xsd:element name="local_pk" type="xsd:string" minOccurs="0" />
|
<xsd:attribute name="capath" type="xsd:string" />
|
||||||
<xsd:element name="passphrase" type="xsd:string" minOccurs="0" />
|
<xsd:attribute name="local-cert" type="xsd:string" />
|
||||||
<xsd:element name="ciphers" type="xsd:string" minOccurs="0" />
|
<xsd:attribute name="local-pk" type="xsd:string" />
|
||||||
<xsd:element name="peer_fingerprint" type="fingerprint" minOccurs="0" maxOccurs="unbounded" />
|
<xsd:attribute name="passphrase" type="xsd:string" />
|
||||||
</xsd:sequence>
|
<xsd:attribute name="ciphers" type="xsd:string" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="http_client_client">
|
<xsd:complexType name="http_client_client">
|
||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
<xsd:element name="default_options" type="http_client_options" minOccurs="0" />
|
<xsd:element name="default-options" type="http_client_options" minOccurs="0" />
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="fingerprint">
|
<xsd:complexType name="fingerprint">
|
||||||
<xsd:sequence>
|
<xsd:choice maxOccurs="unbounded">
|
||||||
<xsd:any minOccurs="0" processContents="lax" maxOccurs="unbounded" />
|
<xsd:element name="pin-sha256" type="xsd:string" minOccurs="0" />
|
||||||
</xsd:sequence>
|
<xsd:element name="sha1" type="xsd:string" minOccurs="0" />
|
||||||
|
<xsd:element name="md5" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:choice>
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="http_query">
|
<xsd:complexType name="http_query" mixed="true">
|
||||||
<xsd:sequence>
|
<xsd:attribute name="key" type="xsd:string" />
|
||||||
<xsd:any minOccurs="0" processContents="lax" maxOccurs="unbounded" />
|
|
||||||
</xsd:sequence>
|
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
|
|
||||||
<xsd:complexType name="http_headers">
|
<xsd:complexType name="http_resolve" mixed="true">
|
||||||
<xsd:sequence>
|
<xsd:attribute name="host" type="xsd:string" />
|
||||||
<xsd:any minOccurs="0" processContents="lax" maxOccurs="unbounded" />
|
</xsd:complexType>
|
||||||
</xsd:sequence>
|
|
||||||
|
<xsd:complexType name="http_header" mixed="true">
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:schema>
|
</xsd:schema>
|
||||||
|
@ -17,6 +17,7 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Configuration;
|
|||||||
use Symfony\Bundle\FullStack;
|
use Symfony\Bundle\FullStack;
|
||||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||||
use Symfony\Component\Config\Definition\Processor;
|
use Symfony\Component\Config\Definition\Processor;
|
||||||
|
use Symfony\Component\HttpClient\HttpClient;
|
||||||
use Symfony\Component\Lock\Store\SemaphoreStore;
|
use Symfony\Component\Lock\Store\SemaphoreStore;
|
||||||
use Symfony\Component\Messenger\MessageBusInterface;
|
use Symfony\Component\Messenger\MessageBusInterface;
|
||||||
|
|
||||||
@ -332,8 +333,7 @@ class ConfigurationTest extends TestCase
|
|||||||
],
|
],
|
||||||
'disallow_search_engine_index' => true,
|
'disallow_search_engine_index' => true,
|
||||||
'http_client' => [
|
'http_client' => [
|
||||||
'enabled' => false,
|
'enabled' => !class_exists(FullStack::class) && class_exists(HttpClient::class),
|
||||||
'max_host_connections' => 6,
|
|
||||||
'clients' => [],
|
'clients' => [],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -3,13 +3,12 @@
|
|||||||
$container->loadFromExtension('framework', [
|
$container->loadFromExtension('framework', [
|
||||||
'http_client' => [
|
'http_client' => [
|
||||||
'default_options' => [
|
'default_options' => [
|
||||||
'auth' => 'foo:bar',
|
'auth_basic' => 'foo:bar',
|
||||||
'query' => ['foo' => 'bar', 'bar' => 'baz'],
|
'query' => ['foo' => 'bar', 'bar' => 'baz'],
|
||||||
'headers' => ['X-powered' => 'PHP'],
|
'headers' => ['X-powered' => 'PHP'],
|
||||||
'max_redirects' => 2,
|
'max_redirects' => 2,
|
||||||
'http_version' => '2.0',
|
'http_version' => '2.0',
|
||||||
'base_uri' => 'http://example.com',
|
'base_uri' => 'http://example.com',
|
||||||
'buffer' => true,
|
|
||||||
'resolve' => ['localhost' => '127.0.0.1'],
|
'resolve' => ['localhost' => '127.0.0.1'],
|
||||||
'proxy' => 'proxy.org',
|
'proxy' => 'proxy.org',
|
||||||
'timeout' => 3.5,
|
'timeout' => 3.5,
|
||||||
|
@ -6,12 +6,11 @@
|
|||||||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||||
|
|
||||||
<framework:config>
|
<framework:config>
|
||||||
<framework:http_client>
|
<framework:http-client max-host-connections="4">
|
||||||
<framework:max_host_connections>4</framework:max_host_connections>
|
<framework:default-options />
|
||||||
<framework:default_options />
|
|
||||||
<framework:client name="foo">
|
<framework:client name="foo">
|
||||||
<framework:default_options />
|
<framework:default-options />
|
||||||
</framework:client>
|
</framework:client>
|
||||||
</framework:http_client>
|
</framework:http-client>
|
||||||
</framework:config>
|
</framework:config>
|
||||||
</container>
|
</container>
|
||||||
|
@ -6,40 +6,34 @@
|
|||||||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||||
|
|
||||||
<framework:config>
|
<framework:config>
|
||||||
<framework:http_client>
|
<framework:http-client>
|
||||||
<framework:default_options>
|
<framework:default-options
|
||||||
<framework:auth>foo:bar</framework:auth>
|
proxy="proxy.org"
|
||||||
<framework:query>
|
bindto="127.0.0.1"
|
||||||
<framework:foo>bar</framework:foo>
|
timeout="3.5"
|
||||||
<framework:bar>baz</framework:bar>
|
verify-peer="true"
|
||||||
</framework:query>
|
auth-basic="foo:bar"
|
||||||
<framework:headers>
|
max-redirects="2"
|
||||||
<framework:X-powered>PHP</framework:X-powered>
|
http-version="2.0"
|
||||||
</framework:headers>
|
base-uri="http://example.com"
|
||||||
<framework:max_redirects>2</framework:max_redirects>
|
verify-host="true"
|
||||||
<framework:http_version>2.0</framework:http_version>
|
cafile="/etc/ssl/cafile"
|
||||||
<framework:base_uri>http://example.com</framework:base_uri>
|
capath="/etc/ssl"
|
||||||
<framework:buffer>true</framework:buffer>
|
local-cert="/etc/ssl/cert.pem"
|
||||||
<framework:resolve>
|
local-pk="/etc/ssl/private_key.pem"
|
||||||
<framework:localhost>127.0.0.1</framework:localhost>
|
passphrase="password123456"
|
||||||
</framework:resolve>
|
ciphers="RC4-SHA:TLS13-AES-128-GCM-SHA256"
|
||||||
<framework:proxy>proxy.org</framework:proxy>
|
>
|
||||||
<framework:timeout>3.5</framework:timeout>
|
<framework:query key="foo">bar</framework:query>
|
||||||
<framework:bindto>127.0.0.1</framework:bindto>
|
<framework:query key="bar">baz</framework:query>
|
||||||
<framework:verify_peer>true</framework:verify_peer>
|
<framework:header name="X-powered">PHP</framework:header>
|
||||||
<framework:verify_host>true</framework:verify_host>
|
<framework:resolve host="localhost">127.0.0.1</framework:resolve>
|
||||||
<framework:cafile>/etc/ssl/cafile</framework:cafile>
|
<framework:peer-fingerprint>
|
||||||
<framework:capath>/etc/ssl</framework:capath>
|
|
||||||
<framework:local_cert>/etc/ssl/cert.pem</framework:local_cert>
|
|
||||||
<framework:local_pk>/etc/ssl/private_key.pem</framework:local_pk>
|
|
||||||
<framework:passphrase>password123456</framework:passphrase>
|
|
||||||
<framework:ciphers>RC4-SHA:TLS13-AES-128-GCM-SHA256</framework:ciphers>
|
|
||||||
<framework:peer_fingerprint>
|
|
||||||
<framework:pin-sha256>14s5erg62v1v8471g2revg48r7==</framework:pin-sha256>
|
<framework:pin-sha256>14s5erg62v1v8471g2revg48r7==</framework:pin-sha256>
|
||||||
<framework:pin-sha256>jsda84hjtyd4821bgfesd215bsfg5412=</framework:pin-sha256>
|
<framework:pin-sha256>jsda84hjtyd4821bgfesd215bsfg5412=</framework:pin-sha256>
|
||||||
<framework:md5>sdhtb481248721thbr=</framework:md5>
|
<framework:md5>sdhtb481248721thbr=</framework:md5>
|
||||||
</framework:peer_fingerprint>
|
</framework:peer-fingerprint>
|
||||||
</framework:default_options>
|
</framework:default-options>
|
||||||
</framework:http_client>
|
</framework:http-client>
|
||||||
</framework:config>
|
</framework:config>
|
||||||
</container>
|
</container>
|
||||||
|
@ -6,19 +6,15 @@
|
|||||||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||||
|
|
||||||
<framework:config>
|
<framework:config>
|
||||||
<framework:http_client>
|
<framework:http-client>
|
||||||
<framework:default_options>
|
<framework:default-options>
|
||||||
<framework:headers>
|
<framework:header name="foo">bar</framework:header>
|
||||||
<framework:foo>bar</framework:foo>
|
</framework:default-options>
|
||||||
</framework:headers>
|
|
||||||
</framework:default_options>
|
|
||||||
<framework:client name="foo">
|
<framework:client name="foo">
|
||||||
<framework:default_options>
|
<framework:default-options>
|
||||||
<framework:headers>
|
<framework:header name="bar">baz</framework:header>
|
||||||
<framework:bar>baz</framework:bar>
|
</framework:default-options>
|
||||||
</framework:headers>
|
|
||||||
</framework:default_options>
|
|
||||||
</framework:client>
|
</framework:client>
|
||||||
</framework:http_client>
|
</framework:http-client>
|
||||||
</framework:config>
|
</framework:config>
|
||||||
</container>
|
</container>
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
framework:
|
framework:
|
||||||
http_client:
|
http_client:
|
||||||
default_options:
|
default_options:
|
||||||
auth: foo:bar
|
auth_basic: foo:bar
|
||||||
query: {'foo': 'bar', 'bar': 'baz'}
|
query: {'foo': 'bar', 'bar': 'baz'}
|
||||||
headers:
|
headers:
|
||||||
X-powered: PHP
|
X-powered: PHP
|
||||||
max_redirects: 2
|
max_redirects: 2
|
||||||
http_version: 2.0
|
http_version: 2.0
|
||||||
base_uri: 'http://example.com'
|
base_uri: 'http://example.com'
|
||||||
buffer: true
|
|
||||||
resolve: {'localhost': '127.0.0.1'}
|
resolve: {'localhost': '127.0.0.1'}
|
||||||
proxy: proxy.org
|
proxy: proxy.org
|
||||||
timeout: 3.5
|
timeout: 3.5
|
||||||
|
@ -1363,8 +1363,6 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
'query' => [],
|
'query' => [],
|
||||||
'headers' => [],
|
'headers' => [],
|
||||||
'resolve' => [],
|
'resolve' => [],
|
||||||
'peer_fingerprint' => [],
|
|
||||||
'http_version' => '',
|
|
||||||
];
|
];
|
||||||
$this->assertSame([$defaultOptions, 4], $container->getDefinition('http_client')->getArguments());
|
$this->assertSame([$defaultOptions, 4], $container->getDefinition('http_client')->getArguments());
|
||||||
|
|
||||||
@ -1387,13 +1385,12 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
|
|
||||||
$defaultOptions = $container->getDefinition('http_client')->getArguments()[0];
|
$defaultOptions = $container->getDefinition('http_client')->getArguments()[0];
|
||||||
|
|
||||||
$this->assertSame('foo:bar', $defaultOptions['auth']);
|
$this->assertSame('foo:bar', $defaultOptions['auth_basic']);
|
||||||
$this->assertSame(['foo' => 'bar', 'bar' => 'baz'], $defaultOptions['query']);
|
$this->assertSame(['foo' => 'bar', 'bar' => 'baz'], $defaultOptions['query']);
|
||||||
$this->assertSame(['x-powered' => ['PHP']], $defaultOptions['headers']);
|
$this->assertSame(['x-powered' => ['PHP']], $defaultOptions['headers']);
|
||||||
$this->assertSame(2, $defaultOptions['max_redirects']);
|
$this->assertSame(2, $defaultOptions['max_redirects']);
|
||||||
$this->assertSame(2.0, (float) $defaultOptions['http_version']);
|
$this->assertSame(2.0, (float) $defaultOptions['http_version']);
|
||||||
$this->assertSame('http://example.com', $defaultOptions['base_uri']);
|
$this->assertSame('http://example.com', $defaultOptions['base_uri']);
|
||||||
$this->assertTrue($defaultOptions['buffer']);
|
|
||||||
$this->assertSame(['localhost' => '127.0.0.1'], $defaultOptions['resolve']);
|
$this->assertSame(['localhost' => '127.0.0.1'], $defaultOptions['resolve']);
|
||||||
$this->assertSame('proxy.org', $defaultOptions['proxy']);
|
$this->assertSame('proxy.org', $defaultOptions['proxy']);
|
||||||
$this->assertSame(3.5, $defaultOptions['timeout']);
|
$this->assertSame(3.5, $defaultOptions['timeout']);
|
||||||
|
Reference in New Issue
Block a user