Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
3 changes: 1 addition & 2 deletions src/DevEtagSetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use BEAR\RepositoryModule\Annotation\HttpCache;
use BEAR\Resource\Request;
use BEAR\Resource\ResourceObject;
use DateTimeInterface;
use Override;

use function gmdate;
Expand All @@ -30,7 +29,7 @@ public function __invoke(ResourceObject $ro, int|null $time = null, HttpCache|nu
// This is useful for debugging purposes.
// Usually, the ETag is a hash of the resource view or body.
$ro->headers[Header::ETAG] = $uriEtag;
$ro->headers[Header::LAST_MODIFIED] = gmdate(DateTimeInterface::RFC7231, 0);
$ro->headers[Header::LAST_MODIFIED] = gmdate(Header::RFC7231, 0);
$this->setCacheDependency($ro);
}

Expand Down
3 changes: 1 addition & 2 deletions src/EtagSetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use BEAR\RepositoryModule\Annotation\HttpCache;
use BEAR\Resource\Request;
use BEAR\Resource\ResourceObject;
use DateTimeInterface;
use Override;

use function assert;
Expand Down Expand Up @@ -38,7 +37,7 @@ public function __invoke(ResourceObject $ro, int|null $time = null, HttpCache|nu

$etag = $this->getEtag($ro, $httpCache);
$ro->headers[Header::ETAG] = $etag;
$ro->headers[Header::LAST_MODIFIED] = gmdate(DateTimeInterface::RFC7231, $time);
$ro->headers[Header::LAST_MODIFIED] = gmdate(Header::RFC7231, $time);
$this->setCacheDependency($ro);
}

Expand Down
7 changes: 7 additions & 0 deletions src/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@ final class Header
public const CACHE_CONTROL = 'Cache-Control';
public const AGE = 'Age';
public const LAST_MODIFIED = 'Last-Modified';

/**
* RFC 7231 date format for HTTP headers
*
* @see https://www.rfc-editor.org/rfc/rfc7231#section-7.1.1.1
*/
public const RFC7231 = 'D, d M Y H:i:s \G\M\T';
public const HTTP_IF_NONE_MATCH = 'HTTP_IF_NONE_MATCH';
}
Loading