Skip to content

Commit 1474fa3

Browse files
Merge pull request nextcloud#52743 from nextcloud/bug/noid/expires-date-format
2 parents 9faf386 + 1ac85a3 commit 1474fa3

6 files changed

Lines changed: 11 additions & 11 deletions

File tree

apps/dav/lib/Provisioning/Apple/AppleProvisioningNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function getProperties($properties) {
5757

5858
return [
5959
'{DAV:}getcontentlength' => 42,
60-
'{DAV:}getlastmodified' => $datetime->format(\DateTimeInterface::RFC2822),
60+
'{DAV:}getlastmodified' => $datetime->format(\DateTimeInterface::RFC7231),
6161
];
6262
}
6363

apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningNodeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testGetProperties(): void {
5454

5555
$this->assertEquals([
5656
'{DAV:}getcontentlength' => 42,
57-
'{DAV:}getlastmodified' => 'Sat, 01 Jan 2000 00:00:00 +0000',
57+
'{DAV:}getlastmodified' => 'Sat, 01 Jan 2000 00:00:00 GMT',
5858
], $this->node->getProperties([]));
5959
}
6060

lib/private/AppFramework/Middleware/NotModifiedMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function afterController($controller, $methodName, Response $response) {
2929
}
3030

3131
$modifiedSinceHeader = $this->request->getHeader('IF_MODIFIED_SINCE');
32-
if ($modifiedSinceHeader !== '' && $response->getLastModified() !== null && trim($modifiedSinceHeader) === $response->getLastModified()->format(\DateTimeInterface::RFC2822)) {
32+
if ($modifiedSinceHeader !== '' && $response->getLastModified() !== null && trim($modifiedSinceHeader) === $response->getLastModified()->format(\DateTimeInterface::RFC7231)) {
3333
$response->setStatus(Http::STATUS_NOT_MODIFIED);
3434
return $response;
3535
}

lib/public/AppFramework/Http/Response.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function cacheFor(int $cacheSeconds, bool $public = false, bool $immutabl
9696
$time = \OCP\Server::get(ITimeFactory::class);
9797
$expires->setTimestamp($time->getTime());
9898
$expires->add(new \DateInterval('PT' . $cacheSeconds . 'S'));
99-
$this->addHeader('Expires', $expires->format(\DateTimeInterface::RFC2822));
99+
$this->addHeader('Expires', $expires->format(\DateTimeInterface::RFC7231));
100100
} else {
101101
$this->addHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
102102
unset($this->headers['Expires']);
@@ -238,7 +238,7 @@ public function getHeaders() {
238238
];
239239

240240
if ($this->lastModified) {
241-
$mergeWith['Last-Modified'] = $this->lastModified->format(\DateTimeInterface::RFC2822);
241+
$mergeWith['Last-Modified'] = $this->lastModified->format(\DateTimeInterface::RFC7231);
242242
}
243243

244244
if ($this->ETag) {

tests/lib/AppFramework/Http/ResponseTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function testCacheSeconds(): void {
229229

230230
$headers = $this->childResponse->getHeaders();
231231
$this->assertEquals('private, max-age=33, must-revalidate', $headers['Cache-Control']);
232-
$this->assertEquals('Thu, 15 Jan 1970 06:56:40 +0000', $headers['Expires']);
232+
$this->assertEquals('Thu, 15 Jan 1970 06:56:40 GMT', $headers['Expires']);
233233
}
234234

235235

@@ -239,7 +239,7 @@ public function testEtagLastModifiedHeaders(): void {
239239
$lastModified->setTimestamp(1);
240240
$this->childResponse->setLastModified($lastModified);
241241
$headers = $this->childResponse->getHeaders();
242-
$this->assertEquals('Thu, 01 Jan 1970 00:00:01 +0000', $headers['Last-Modified']);
242+
$this->assertEquals('Thu, 01 Jan 1970 00:00:01 GMT', $headers['Last-Modified']);
243243
}
244244

245245
public function testChainability(): void {
@@ -257,7 +257,7 @@ public function testChainability(): void {
257257
$this->assertEquals('world', $headers['hello']);
258258
$this->assertEquals(Http::STATUS_NOT_FOUND, $this->childResponse->getStatus());
259259
$this->assertEquals('hi', $this->childResponse->getEtag());
260-
$this->assertEquals('Thu, 01 Jan 1970 00:00:01 +0000', $headers['Last-Modified']);
260+
$this->assertEquals('Thu, 01 Jan 1970 00:00:01 GMT', $headers['Last-Modified']);
261261
$this->assertEquals('private, max-age=33, must-revalidate',
262262
$headers['Cache-Control']);
263263
}

tests/lib/AppFramework/Middleware/NotModifiedMiddlewareTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ public static function dataModified(): array {
4343
[null, '"etag"', null, '', false],
4444
['etag', '"etag"', null, '', true],
4545

46-
[null, '', $now, $now->format(\DateTimeInterface::RFC2822), true],
46+
[null, '', $now, $now->format(\DateTimeInterface::RFC7231), true],
4747
[null, '', $now, $now->format(\DateTimeInterface::ATOM), false],
48-
[null, '', null, $now->format(\DateTimeInterface::RFC2822), false],
48+
[null, '', null, $now->format(\DateTimeInterface::RFC7231), false],
4949
[null, '', $now, '', false],
5050

5151
['etag', '"etag"', $now, $now->format(\DateTimeInterface::ATOM), true],
52-
['etag', '"etag"', $now, $now->format(\DateTimeInterface::RFC2822), true],
52+
['etag', '"etag"', $now, $now->format(\DateTimeInterface::RFC7231), true],
5353
];
5454
}
5555

0 commit comments

Comments
 (0)