@@ -2877,39 +2877,45 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
28772877 $ retryOptions = $ scopeConfig ['retry_failed ' ] ?? ['enabled ' => false ];
28782878 unset($ scopeConfig ['retry_failed ' ]);
28792879
2880+ $ transport = $ name .'.transport ' ;
2881+ $ container ->register ($ transport , HttpClientInterface::class)
2882+ ->setFactory ('current ' )
2883+ ->setArguments ([[new Reference ('http_client.transport ' )]])
2884+ ;
2885+
28802886 if (null === $ scope ) {
28812887 $ baseUri = $ scopeConfig ['base_uri ' ];
28822888 unset($ scopeConfig ['base_uri ' ]);
28832889
28842890 $ container ->register ($ name , ScopingHttpClient::class)
28852891 ->setFactory ([ScopingHttpClient::class, 'forBaseUri ' ])
2886- ->setArguments ([new Reference (' http_client. transport' ), $ baseUri , $ scopeConfig ])
2892+ ->setArguments ([new Reference ($ transport ), $ baseUri , $ scopeConfig ])
28872893 ->addTag ('http_client.client ' )
28882894 ->addTag ('kernel.reset ' , ['method ' => 'reset ' , 'on_invalid ' => 'ignore ' ])
28892895 ;
28902896 } else {
28912897 $ container ->register ($ name , ScopingHttpClient::class)
2892- ->setArguments ([new Reference (' http_client. transport' ), [$ scope => $ scopeConfig ], $ scope ])
2898+ ->setArguments ([new Reference ($ transport ), [$ scope => $ scopeConfig ], $ scope ])
28932899 ->addTag ('http_client.client ' )
28942900 ->addTag ('kernel.reset ' , ['method ' => 'reset ' , 'on_invalid ' => 'ignore ' ])
28952901 ;
28962902 }
28972903
28982904 if ($ this ->readConfigEnabled ('http_client.scoped_clients. ' .$ name .'.caching ' , $ container , $ cachingOptions )) {
2899- $ this ->registerCachingHttpClient ($ cachingOptions , $ scopeConfig , $ name , $ container );
2905+ $ this ->registerCachingHttpClient ($ cachingOptions , $ scopeConfig , $ transport , $ container );
29002906 }
29012907
29022908 if (null !== $ rateLimiter ) {
2903- $ this ->registerThrottlingHttpClient ($ rateLimiter , $ name , $ container );
2909+ $ this ->registerThrottlingHttpClient ($ rateLimiter , $ transport , $ container );
29042910 }
29052911
29062912 if ($ this ->readConfigEnabled ('http_client.scoped_clients. ' .$ name .'.retry_failed ' , $ container , $ retryOptions )) {
2907- $ this ->registerRetryableHttpClient ($ retryOptions , $ name , $ container );
2913+ $ this ->registerRetryableHttpClient ($ retryOptions , $ transport , $ container );
29082914 }
29092915
29102916 $ container
29112917 ->register ($ name .'.uri_template ' , UriTemplateHttpClient::class)
2912- ->setDecoratedService ($ name , null , 7 ) // Between TraceableHttpClient (5) and RetryableHttpClient (10)
2918+ ->setDecoratedService ($ name , null , 7 ) // After TraceableHttpClient (5) and on top of ScopingHttpClient
29132919 ->setArguments ([
29142920 new Reference ($ name .'.uri_template.inner ' ),
29152921 new Reference ('http_client.uri_template_expander ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ),
@@ -2943,7 +2949,7 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
29432949 private function registerCachingHttpClient (array $ options , array $ defaultOptions , string $ name , ContainerBuilder $ container ): void
29442950 {
29452951 if (!class_exists (ChunkCacheItemNotFoundException::class)) {
2946- throw new LogicException ('Caching cannot be enabled as version 7.3 + of the HttpClient component is required. ' );
2952+ throw new LogicException ('Caching cannot be enabled as version 7.4 + of the HttpClient component is required. ' );
29472953 }
29482954
29492955 $ container
0 commit comments