Description
Symfony version(s) affected: 4.4.* / 5.0.* / 5.1.* (probably others)
Description
While using Symfony\Component\HttpClient\CachingHttpClient
with a Symfony\Component\HttpKernel\HttpCache\Store
we found that responses returned from the cache did not yield the correct response bodies.
I checked the source and found the following snippet:
symfony/src/Symfony/Component/HttpKernel/HttpCache/Store.php
Lines 153 to 155 in 749380a
This seems rather odd to me because after executing $body = $this->getPath($headers['x-content-digest'][0])
$body
contains the path to the cached response body file and not the cached response body itself. But $body
(containing the path and not the response body) is then fed into Symfony\Component\HttpKernel\HttpCache\Store::restoreResponse()
where it's used to populate the Symfony\Component\HttpFoundation\Response
content. So the returned response contains the path to the cached response body file in its body instead of the actual response content.
How to reproduce
Just use a Symfony\Component\HttpClient\CachingHttpClient
configured with a Symfony\Component\HttpKernel\HttpCache\Store
and fetch the same HTTP resource twice.
Possible Solution
I might be wrong, but to me it looks like there's a file_get_contents()
missing.