Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[HttpClient] Fix scoped client without query option configuration #36377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
->thenInvalid('Either "scope" or "base_uri" should be defined.')
->end()
->validate()
->ifTrue(function ($v) { return isset($v['query']) && !isset($v['base_uri']); })
->ifTrue(function ($v) { return !empty($v['query']) && !isset($v['base_uri']); })
->thenInvalid('"query" applies to "base_uri" but no base URI is defined.')
->end()
->children()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

$container->loadFromExtension('framework', [
'http_client' => [
'scoped_clients' => [
'foo' => [
'scope' => '.*',
],
],
],
]);
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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:scoped-client
name="foo"
scope=".*"
/>
</framework:http-client>
</framework:config>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
framework:
http_client:
scoped_clients:
foo:
scope: '.*'
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,14 @@ public function testHttpClientDefaultOptions()
$this->assertSame(ScopingHttpClient::class, $container->getDefinition('foo')->getClass());
}

public function testScopedHttpClientWithoutQueryOption()
{
$container = $this->createContainerFromFile('http_client_scoped_without_query_option');

$this->assertTrue($container->hasDefinition('foo'), 'should have the "foo" service.');
$this->assertSame(ScopingHttpClient::class, $container->getDefinition('foo')->getClass());
}

public function testHttpClientOverrideDefaultOptions()
{
$container = $this->createContainerFromFile('http_client_override_default_options');
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.