Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[HttpKernel] Fix regression where Store does not return response body correctly#37182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
nicolas-grekas approved these changesJun 11, 2020
fabpot approved these changesJun 11, 2020
| * | ||
| * A restored response does *not* load the body, but only keep the file path in a special X-Body-File | ||
| * header. For reasons (?), the file path was also used as the restored response body. | ||
| * It would be up to others (HttpCache...?) to hohor this header and actually load the response content |
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
honor
Member
fabpot commentedJun 11, 2020
Thank you@mpdude. |
| * | ||
| * @param array $headers An array of HTTP headers for the Response | ||
| * @param string $bodyThe Response body | ||
| * @param string $pathPath to the Response body |
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
string|null
This was referencedJun 12, 2020
Merged
Merged
Merged
Merged
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading.Please reload this page.
Since#36833, the
Storeno longer uses or trusts theX-Content-Digestheader present on a response, since that may come (in the case of usingCachingHttpClient) from upstream HTTP sources. Instead, theX-Content-Digestis re-computed every time a response is written by theStore.Additionally, the
Storeis implemented in a way that when restoring responses, it doesnot actually load the response body, but just keeps the file path to the content on disk in another internal header calledX-Body-File. It is up to others (HttpCache, for example) to actually load the content from there. For reasons I could not determine, the file path is also set as the response body.When the
HttpCacheperforms revalidations, it may happen that it wants theStoreto persist a previously restored response. In that case, theStorefails to honor its ownX-Body-Fileheader. Instead, it would compute (since#36833) theX-Content-Digest, which now is a hash of the cache file path.So, we end up with a response that still carries
X-Body-Filefor the original, correct response. Since theHttpCachehonors this value, we don't immediately notice that. But inside theStore, the request is now associated with thenew (bogus) content entry.It takes another round of looking up the content in the
Storeto now get a response where theX-Body-Filealso points to the wrong content entry.Although I feel a bit uncomfortable with trusting headers that seemingly need to be evaluated in different classes and may come from elsewhere, my suggestion is to skip the write inside
StoreifX-Body-FileandX-Content-Digestare both present and consistent with each other.Additionally, a
file_existscheck could be added to provide additional assertions, at the cost of accessing the filesystem.