8000 Response::isNotModified returns true when If-Modified-Since is later than Last-Modified by skolodyazhnyy · Pull Request #11079 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Response::isNotModified returns true when If-Modified-Since is later than Last-Modified #11079

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 2 commits into from
Closed

Response::isNotModified returns true when If-Modified-Since is later than Last-Modified #11079

wants to merge 2 commits into from

Conversation

skolodyazhnyy
Copy link
Contributor
Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #10501, #10857
License MIT
Doc PR

Patch for #10501. I have reworked a bit Response::isNotModified method to make it more readable. Now it's comparing If-Modified-Since and Last-Modified as dates.

@@ -1075,19 +1075,23 @@ public function isNotModified(Request $request)
return false;
}

$lastModified = $request->headers->get('If-Modified-Since');
$notModified = false;
$modified = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

The variable was probably named $notModified to follow the related HTTP status code name (304 NOT MODIFIED), I think you should keep the negation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, It seems to me that it's easier to understand logic if there is no negation

Copy link
Contributor

Choose a reason for hiding this comment

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

If you apply this logic, you need to rename the method as well.

$notModified is just a special name and I would keep it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't get how method name is related to variables in it, but OK. I have renamed variable.

@stof
Copy link
Member
stof commented Jul 17, 2014

I think your change also fixes #10857. could you add a testcase covering it ?

@skolodyazhnyy
Copy link
Contributor Author

@stof Done. If I understand it right, the problem with #10857 appears when there is both request headers specified, but response has only etag. If response has non - logic was fine.


$response->headers->set('ETag', 'non-existent-etag');
$response->headers->remove('Last-Modified');
$this->assertFalse($response->isNotModified($request));
Copy link
Member

Choose a reason for hiding this comment

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

These cases were the response does not have a Last-Modified header but the request has If-Modified-Since should be moved to a separate test method to be more readable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stof Can you, please, suggest a test method name? :) Is there any rules for test method naming?

Copy link
Member

Choose a reason for hiding this comment

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

the test method name shoud describe what the test covers

testIfModififiedSinceWithoutLastModified might be a good name for instance

@stof
Copy link
Member
stof commented Jul 17, 2014

once the issue I reported is fixed, 👍

@skolodyazhnyy
Copy link
Contributor Author

@stof Thanks, it's fixed

@fabpot
Copy link
Member
fabpot commented Sep 23, 2014

Thank you @skolodyazhnyy.

fabpot added a commit that referenced this pull request Sep 23, 2014
…e is later than Last-Modified (skolodyazhnyy)

This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #11079).

Discussion
----------

Response::isNotModified returns true when If-Modified-Since is later than Last-Modified

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

Patch for #10501. I have reworked a bit `Response::isNotModified` method to make it more readable. Now it's comparing If-Modified-Since and Last-Modified as dates.

Commits
-------

42ec76e Response::isNotModified returns true when If-Modified-Since is later than Last-Modified
@fabpot fabpot closed this Sep 23, 2014
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.

5 participants
0