-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,39 @@ public function testWritesResponseEvenIfXContentDigestIsPresent() | |
$this->assertNotNull($response); | ||
} | ||
|
||
public function testWritingARestoredResponseDoesNotCorruptCache() | ||
{ | ||
/* | ||
* This covers the regression reported in https://github.com/symfony/symfony/issues/37174. | ||
* | ||
* 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. honor |
||
* from there. | ||
* | ||
* When a restored response was stored again, the Store itself would ignore the header. In the first | ||
* step, this would compute a new Content Digest based on the file path in the restored response body; | ||
* this is covered by "Checkpoint 1" below. But, since the X-Body-File header was left untouched (Checkpoint 2), downstream | ||
* code (HttpCache...) would not immediately notice. | ||
* | ||
* Only upon performing the lookup for a second time, we'd get a Response where the (wrong) Content Digest | ||
* is also reflected in the X-Body-File header, this time also producing wrong content when the downstream | ||
* evaluates it. | ||
*/ | ||
$this->store->write($this->request, $this->response); | ||
$digest = $this->response->headers->get('X-Content-Digest'); | ||
$path = $this->getStorePath($digest); | ||
|
||
$response = $this->store->lookup($this->request); | ||
$this->store->write($this->request, $response); | ||
$this->assertEquals($digest, $response->headers->get('X-Content-Digest')); // Checkpoint 1 | ||
$this->assertEquals($path, $response->headers->get('X-Body-File')); // Checkpoint 2 | ||
|
||
$response = $this->store->lookup($this->request); | ||
$this->assertEquals($digest, $response->headers->get('X-Content-Digest')); | ||
$this->assertEquals($path, $response->headers->get('X-Body-File')); | ||
} | ||
|
||
public function testFindsAStoredEntryWithLookup() | ||
{ | ||
$this->storeSimpleEntry(); | ||
|
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.
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