Skip to content

[HttpKernel] Fixed two bugs in HttpCache #8098

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

Closed
wants to merge 1 commit into from
Closed

[HttpKernel] Fixed two bugs in HttpCache #8098

wants to merge 1 commit into from

Conversation

jdesrosiers
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #8097
License MIT
Doc PR
  1. 304 responses always send "Content-Type: text/html; charset=UTF-8"
    header
    I discovered that the HttpCache::handle method calls Response::prepare
    after calling Response::isModified. Response::isModified removes the
    Content-Type header as it should, but Response::handle adds in the
    default Content-Type header when none is set. If the default
    Content-Type is not the correct Content-Type, then the Content-Type in
    the cache gets clobered. I solved this problem by moving the
    Response::isModified call after the Response::prepare call. I updated
    the testRespondsWith304WhenIfModifiedSinceMatchesLastModified and
    testRespondsWith304WhenIfNoneMatchMatchesETag tests to verify that the
    Content-Type header was not being sent for 304 responses.
  2. Failure to invalidate cached entities referred to by the Location
    header
    I discovered that the Store::invalidate method was looking for Location
    and Content-Location headers to invalidate, but it was looking in the
    request headers instead of the response headers. Because the
    Store::invalidate method doesn't take a response, I decided it was
    better to move this logic to the HttpCache::invalidate method instead.
    I updated the testInvalidatesCachedResponsesOnPost test to verify that
    Location headers are getting invalidated correctly.

1. 304 responses always send "Content-Type: text/html; charset=UTF-8"
header
I discovered that the HttpCache::handle method calls Response::prepare
after calling Response::isModified.  Response::isModified removes the
Content-Type header as it should, but Response::handle adds in the
default Content-Type header when none is set.  If the default
Content-Type is not the correct Content-Type, then the Content-Type in
the cache gets clobered.  I solved this problem by moving the
Response::isModified call after the Response::prepare call.  I updated
the testRespondsWith304WhenIfModifiedSinceMatchesLastModified and
testRespondsWith304WhenIfNoneMatchMatchesETag tests to verify that the
Content-Type header was not being sent for 304 responses.

2. Failure to invalidate cached entities referred to by the Location
header
I discovered that the Store::invalidate method was looking for Location
and Content-Location headers to invalidate, but it was looking in the
request headers instead of the response headers.  Because the
Store::invalidate method doesn't take a response, I decided it was
better to move this logic to the HttpCache::invalidate method instead.
I updated the testInvalidatesCachedResponsesOnPost test to verify that
Location headers are getting invalidated correctly.
@jdesrosiers
Copy link
Contributor Author

I see that the Travis CI build failed and wanted to point out that the tests that are failing are related to YAML and are not caused by the changes in this patch. This patch only affects the HttpKernel component and all of those tests are passing.

@stof
Copy link
Member

stof commented May 20, 2013

2.0 is not maintained anymore. Please send these changes to 2.1 instead

fabpot added a commit that referenced this pull request May 20, 2013
This PR was submitted for the 2.0 branch but it was merged into the 2.1 branch instead (closes #8098).

Discussion
----------

[HttpKernel] Fixed two bugs in HttpCache

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #8097
| License       | MIT
| Doc PR        |

1. 304 responses always send "Content-Type: text/html; charset=UTF-8"
header
I discovered that the HttpCache::handle method calls Response::prepare
after calling Response::isModified.  Response::isModified removes the
Content-Type header as it should, but Response::handle adds in the
default Content-Type header when none is set.  If the default
Content-Type is not the correct Content-Type, then the Content-Type in
the cache gets clobered.  I solved this problem by moving the
Response::isModified call after the Response::prepare call.  I updated
the testRespondsWith304WhenIfModifiedSinceMatchesLastModified and
testRespondsWith304WhenIfNoneMatchMatchesETag tests to verify that the
Content-Type header was not being sent for 304 responses.

2. Failure to invalidate cached entities referred to by the Location
header
I discovered that the Store::invalidate method was looking for Location
and Content-Location headers to invalidate, but it was looking in the
request headers instead of the response headers.  Because the
Store::invalidate method doesn't take a response, I decided it was
better to move this logic to the HttpCache::invalidate method instead.
I updated the testInvalidatesCachedResponsesOnPost test to verify that
Location headers are getting invalidated correctly.

Commits
-------

a4251bd [HttpKernel] Fixed two bugs in HttpCache
@fabpot fabpot closed this May 20, 2013
@jdesrosiers
Copy link
Contributor Author

Sorry, I didn't realize 2.0 was no longer supported. Thanks.

@jdesrosiers jdesrosiers deleted the ticket_8097 branch May 21, 2013 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy