-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Description
Symfony version(s) affected
7.4
Description
When using the Caching HTTP Client with a scoped client, an exception Invalid URL: scheme is missing is thrown on the request
How to reproduce
Either creating the scoped client manually:
$client = new CachingHttpClient(
ScopingHttpClient::forBaseUri(HttpClient::create(), 'https://api.github.com'),
new TagAwareAdapter(new ArrayAdapter()),
);
$release = $client->request('GET', '/repos/symfony/symfony/releases/latest');or using the framework.yaml config:
framework:
http_client:
scoped_clients:
github.client:
base_uri: 'https://api.github.com'
caching:
cache_pool: cache.app.taggableWhen doing a request without the scheme and domain (E.G $release = $client->request('GET', '/repos/symfony/symfony/releases/latest');), the following exception is thrown:
Invalid URL: scheme is missing in "/repos/symfony/symfony/releases/latest". Did you forget to add "http(s)://"?
This is because the CachingHttpClient calls self::prepareRequest first thing in the request method, which validated the URL and throws the exception before giving the ScopingHttpClient a chance to set the base uri
| [$fullUrl, $options] = self::prepareRequest($method, $url, $options, $this->defaultOptions); |
cc: @Lctrs
Possible Solution
No response
Additional Context
No response