@@ -2342,7 +2342,7 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
2342
2342
unset($ options ['retry_failed ' ]);
2343
2343
$ defaultUriTemplateVars = $ options ['vars ' ] ?? [];
2344
2344
unset($ options ['vars ' ]);
2345
- $ container ->getDefinition ('http_client ' )->setArguments ([$ options , $ config ['max_host_connections ' ] ?? 6 ]);
2345
+ $ container ->getDefinition ('http_client.transport ' )->setArguments ([$ options , $ config ['max_host_connections ' ] ?? 6 ]);
2346
2346
2347
2347
if (!$ hasPsr18 = ContainerBuilder::willBeAvailable ('psr/http-client ' , ClientInterface::class, ['symfony/framework-bundle ' , 'symfony/http-client ' ])) {
2348
2348
$ container ->removeDefinition ('psr18.http_client ' );
@@ -2353,7 +2353,7 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
2353
2353
$ container ->removeDefinition (HttpClient::class);
2354
2354
}
2355
2355
2356
- if ($ hasRetryFailed = $ this ->readConfigEnabled ('http_client.retry_failed ' , $ container , $ retryOptions )) {
2356
+ if ($ this ->readConfigEnabled ('http_client.retry_failed ' , $ container , $ retryOptions )) {
2357
2357
$ this ->registerRetryableHttpClient ($ retryOptions , 'http_client ' , $ container );
2358
2358
}
2359
2359
@@ -2371,15 +2371,8 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
2371
2371
throw new LogicException ('Support for URI template requires symfony/http-client 6.3 or higher, try upgrading. ' );
2372
2372
}
2373
2373
2374
- $ httpClientId = match (true ) {
2375
- $ hasUriTemplate => 'http_client.uri_template.inner ' ,
2376
- $ hasRetryFailed => 'http_client.retryable.inner ' ,
2377
- $ this ->isInitializedConfigEnabled ('profiler ' ) => '.debug.http_client.inner ' ,
2378
- default => 'http_client ' ,
2379
- };
2380
-
2381
2374
foreach ($ config ['scoped_clients ' ] as $ name => $ scopeConfig ) {
2382
- if (' http_client ' === $ name ) {
2375
+ if ($ container -> has ( $ name) ) {
2383
2376
throw new InvalidArgumentException (sprintf ('Invalid scope name: "%s" is reserved. ' , $ name ));
2384
2377
}
2385
2378
@@ -2394,17 +2387,17 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
2394
2387
2395
2388
$ container ->register ($ name , ScopingHttpClient::class)
2396
2389
->setFactory ([ScopingHttpClient::class, 'forBaseUri ' ])
2397
- ->setArguments ([new Reference ($ httpClientId ), $ baseUri , $ scopeConfig ])
2390
+ ->setArguments ([new Reference (' http_client.transport ' ), $ baseUri , $ scopeConfig ])
2398
2391
->addTag ('http_client.client ' )
2399
2392
;
2400
2393
} else {
2401
2394
$ container ->register ($ name , ScopingHttpClient::class)
2402
- ->setArguments ([new Reference ($ httpClientId ), [$ scope => $ scopeConfig ], $ scope ])
2395
+ ->setArguments ([new Reference (' http_client.transport ' ), [$ scope => $ scopeConfig ], $ scope ])
2403
2396
->addTag ('http_client.client ' )
2404
2397
;
2405
2398
}
2406
2399
2407
- if ($ this ->readConfigEnabled ('http_client.scoped_clients. ' .$ name .'retry_failed ' , $ container , $ retryOptions )) {
2400
+ if ($ this ->readConfigEnabled ('http_client.scoped_clients. ' .$ name .'. retry_failed ' , $ container , $ retryOptions )) {
2408
2401
$ this ->registerRetryableHttpClient ($ retryOptions , $ name , $ container );
2409
2402
}
2410
2403
@@ -2413,7 +2406,7 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
2413
2406
->register ($ name .'.uri_template ' , UriTemplateHttpClient::class)
2414
2407
->setDecoratedService ($ name , null , 7 ) // Between TraceableHttpClient (5) and RetryableHttpClient (10)
2415
2408
->setArguments ([
2416
- new Reference (' .inner ' ),
2409
+ new Reference ($ name . ' .uri_template .inner ' ),
2417
2410
new Reference ('http_client.uri_template_expander ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ),
2418
2411
$ defaultUriTemplateVars ,
2419
2412
]);
@@ -2430,8 +2423,8 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
2430
2423
}
2431
2424
2432
2425
if ($ responseFactoryId = $ config ['mock_response_factory ' ] ?? null ) {
2433
- $ container ->register ($ httpClientId . ' .mock_client ' , MockHttpClient::class)
2434
- ->setDecoratedService ($ httpClientId , null , -10 ) // lower priority than TraceableHttpClient
2426
+ $ container ->register (' http_client .mock_client ' , MockHttpClient::class)
2427
+ ->setDecoratedService (' http_client.transport ' , null , -10 ) // lower priority than TraceableHttpClient (5)
2435
2428
->setArguments ([new Reference ($ responseFactoryId )]);
2436
2429
}
2437
2430
}
@@ -2464,7 +2457,7 @@ private function registerRetryableHttpClient(array $options, string $name, Conta
2464
2457
2465
2458
$ container
2466
2459
->register ($ name .'.retryable ' , RetryableHttpClient::class)
2467
- ->setDecoratedService ($ name , null , 10 ) // higher priority than TraceableHttpClient
2460
+ ->setDecoratedService ($ name , null , 10 ) // higher priority than TraceableHttpClient (5)
2468
2461
->setArguments ([new Reference ($ name .'.retryable.inner ' ), $ retryStrategy , $ options ['max_retries ' ], new Reference ('logger ' )])
2469
2462
->addTag ('monolog.logger ' , ['channel ' => 'http_client ' ]);
2470
2463
}
0 commit comments