Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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
fabpot merged 1 commit intosymfony:3.4frommpdude:issue-37174
Jun 11, 2020

Conversation

@mpdude
Copy link
Contributor

@mpdudempdude commentedJun 10, 2020
edited
Loading

QA
Branch?3.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#37174
LicenseMIT
Doc PR

Since#36833, theStore no longer uses or trusts theX-Content-Digest header present on a response, since that may come (in the case of usingCachingHttpClient) from upstream HTTP sources. Instead, theX-Content-Digest is re-computed every time a response is written by theStore.

Additionally, theStore is 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 theHttpCache performs revalidations, it may happen that it wants theStore to persist a previously restored response. In that case, theStore fails to honor its ownX-Body-File header. 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 carriesX-Body-File for the original, correct response. Since theHttpCache honors 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 theStore to 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 insideStore ifX-Body-File andX-Content-Digest are both present and consistent with each other.

Additionally, afile_exists check could be added to provide additional assertions, at the cost of accessing the filesystem.

@xabbuhxabbuh added this to the3.4 milestoneJun 10, 2020
@nicolas-grekasnicolas-grekas changed the title[HttpKernel] Fix regression caused by #36833[HttpKernel] Fix regression where Store does not return response body correctlyJun 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

honor

@fabpot
Copy link
Member

Thank you@mpdude.

@fabpotfabpot merged commit54c9054 intosymfony:3.4Jun 11, 2020
@mpdudempdude deleted the issue-37174 branchJune 11, 2020 14:51
*
* @param array $headers An array of HTTP headers for the Response
* @param string $bodyThe Response body
* @param string $pathPath to the Response body
Copy link
Contributor

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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+1 more reviewer

@GrahamCampbellGrahamCampbellGrahamCampbell left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

6 participants

@mpdude@fabpot@nicolas-grekas@GrahamCampbell@xabbuh@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp