mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 08:29:10 -05:00
Properly return 304
The ETag set in the IF_NONE_MODIFIED header is wraped in quotes (").
However the ETag that is set in response is not (yet). Also we need to
cast the ETag to a string.
* Added unit test
This commit is contained in:
parent
e367f1bfc1
commit
f12caf930e
2 changed files with 9 additions and 1 deletions
|
|
@ -121,7 +121,7 @@ class Http extends BaseHttp {
|
|||
|
||||
// if etag or lastmodified have not changed, return a not modified
|
||||
if ((isset($this->server['HTTP_IF_NONE_MATCH'])
|
||||
&& trim($this->server['HTTP_IF_NONE_MATCH']) === $ETag)
|
||||
&& trim(trim($this->server['HTTP_IF_NONE_MATCH']), '"') === (string)$ETag)
|
||||
|
||||
||
|
||||
|
||||
|
|
|
|||
|
|
@ -65,6 +65,14 @@ class HttpTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
|
||||
public function testQuotedEtagMatchReturnsNotModified() {
|
||||
$http = new Http(array('HTTP_IF_NONE_MATCH' => '"hi"'));
|
||||
|
||||
$header = $http->getStatusHeader(Http::STATUS_OK, null, 'hi');
|
||||
$this->assertEquals('HTTP/1.1 304 Not Modified', $header);
|
||||
}
|
||||
|
||||
|
||||
public function testLastModifiedMatchReturnsNotModified() {
|
||||
$dateTime = new \DateTime(null, new \DateTimeZone('GMT'));
|
||||
$dateTime->setTimestamp('12');
|
||||
|
|
|
|||
Loading…
Reference in a new issue