symfony: [HttpKernel] HttpCache\Store does not return response body correctly
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:
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.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (13 by maintainers)
Commits related to this issue
- Fix regression caused by #36833 and reported in #37174. — committed to mpdude/symfony by mpdude 4 years ago
- bug #37182 [HttpKernel] Fix regression where Store does not return response body correctly (mpdude) This PR was squashed before being merged into the 3.4 branch. Discussion ---------- [HttpKernel] ... — committed to symfony/symfony by fabpot 4 years ago
@mpdude Just updates to Symfony 4.4.10 and the problem seems to be solved. Thanks for your quick action!
/cc @mpdude maybe?