Skip to content
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

[HttpFoundation] fixed the check of 'proxy-revalidate' in Response::mustRevalidate() #15263

Closed
wants to merge 2 commits into from
Closed

[HttpFoundation] fixed the check of 'proxy-revalidate' in Response::mustRevalidate() #15263

wants to merge 2 commits into from

Conversation

axiac
Copy link
Contributor

@axiac axiac commented Jul 11, 2015

Q A
Fixed tickets #15262
License MIT

'proxy-revalidate' is not a header on its own but a 'Cache-Control' directive
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9

@xabbuh
Copy link
Member

xabbuh commented Jul 12, 2015

The change looks good to me, but you should add a test for this to avoid future regressions.

@jakzal
Copy link
Contributor

jakzal commented Jul 27, 2015

@axiac have you got time to add a test? Would be also nice if you rebased to the latest 2.3 branch as tests are currently failing on your PR.

…ustRevalidate()

'proxy-revalidate' is not a header on its own but a 'Cache-Control' directive
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9

This fixes issue #15262
@axiac
Copy link
Contributor Author

axiac commented Jul 30, 2015

Sorry to answer so late, I was away from computer during the last two weeks and a half.

The directive proxy-revalidate is not used anywhere else in the Symfony's code or tests, the only place where it appears is the line I changed. I'm not sure how to test it (I'm not even sure I understand correctly how the Cache-Control directives work together).

In order to have something to test I think I should add a way to set the proxy-revalidate directive to the Response.

I am new to Symfony (I started working with it this year) and I am not sure what is the best way to do this. This is why I tried these alternative approaches:

  • add a new method setProxyRevalidate() to the public API of class Response - see commit 337e288; for symmetry I should also add the method setMustRevalidate();
  • change method Response#setCache() to provide support for must-revalidate and proxy-revalidate cache control directives - see commit 440bba7;
  • both of the above - combined in commit cc92569.

Which approach do you think fits best with the current API (and design) of the Response class?

@xabbuh
Copy link
Member

xabbuh commented Aug 2, 2015

@axiac For example, you could add the following two tests after testMustValidate() to the ResponseTest class (the second test would fail without your patch):

    public function testMustRevalidateWithMustRevalidateCacheControlHeader()
    {
        $response = new Response();
        $response->headers->set('cache-control', 'must-revalidate');

        $this->assertTrue($response->mustRevalidate());
    }

    public function testMustRevalidateWithProxyRevalidateCacheControlHeader()
    {
        $response = new Response();
        $response->headers->set('cache-control', 'proxy-revalidate');

        $this->assertTrue($response->mustRevalidate());
    }

@axiac
Copy link
Contributor Author

axiac commented Aug 3, 2015

@xabbuh The tests you suggested look like they belong there. Thank you for your support.

@stof
Copy link
Member

stof commented Aug 3, 2015

👍

Status: reviewed

@xabbuh
Copy link
Member

xabbuh commented Aug 3, 2015

👍

@stof
Copy link
Member

stof commented Aug 3, 2015

Good catch, thanks @axiac.

stof added a commit that referenced this pull request Aug 3, 2015
…Response::mustRevalidate() (axiac)

This PR was squashed before being merged into the 2.3 branch (closes #15263).

Discussion
----------

[HttpFoundation] fixed the check of 'proxy-revalidate' in Response::mustRevalidate()

| Q             | A
| ------------- | ---
| Fixed tickets | #15262
| License       | MIT

'proxy-revalidate' is not a header on its own but a 'Cache-Control' directive
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9

Commits
-------

6c22f0a [HttpFoundation] fixed the check of 'proxy-revalidate' in Response::mustRevalidate()
@stof stof closed this Aug 3, 2015
@axiac axiac deleted the cache-control-proxy-revalidate branch August 4, 2015 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants