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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Test case for #10857: Response::isNotModified() should not force pres…
…ence of Last-Modified header
  • Loading branch information
skolodyazhnyy committed Jul 17, 2014
commit d1d4bc0d008c662e592682b1855e636f8ac3bac3
19 changes: 18 additions & 1 deletion src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public function testIsNotModifiedLastModified()
$request->headers->set('If-Modified-Since', $modified);

$response = new Response();
$response->headers->set('Last-Modified', $modified);

$response->headers->set('Last-Modified', $modified);
$this->assertTrue($response->isNotModified($request));
Expand Down Expand Up @@ -210,6 +209,24 @@ public function testIsNotModifiedLastModifiedAndEtag()
$this->assertTrue($response->isNotModified($request));
}

public function testIsNotModifiedIfModifiedSinceAndEtagWithoutLastModified()
{
$modified = 'Sun, 25 Aug 2013 18:33:31 GMT';
$etag = 'randomly_generated_etag';

$request = new Request();
$request->headers->set('if_none_match', sprintf('%s, %s', $etag, 'etagThree'));
$request->headers->set('If-Modified-Since', $modified);

$response = new Response();

$response->headers->set('ETag', $etag);
$this->assertTrue($response->isNotModified($request));

$response->headers->set('ETag', 'non-existent-etag');
$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

}

public function testIsValidateable()
{
$response = new Response('', 200, array('Last-Modified' => $this->createDateTimeOneHourAgo()->format(DATE_RFC2822)));
Expand Down
0