mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-22 09:35:28 +03:00
* Fix: content.php: last-modified/if-unmodified-since (#3771) Fix exception if server sent invalid Last-Modified header Add support for Unix time instead of standard date string Send back standard RFC7231 date string instead of Unix time * Fix: content.php: if-unmodified-since: cURL API Use getTimestamp() as cURL expects that and will format the If-Modified-Since header appropriately.
This commit is contained in:
parent
8ff39f64f7
commit
4f7451895b
1 changed files with 7 additions and 2 deletions
|
@ -63,8 +63,13 @@ function getContents(
|
|||
if ($cachedResponse) {
|
||||
$cachedLastModified = $cachedResponse->getHeader('last-modified');
|
||||
if ($cachedLastModified) {
|
||||
$cachedLastModified = new \DateTimeImmutable($cachedLastModified);
|
||||
try {
|
||||
// Some servers send Unix timestamp instead of RFC7231 date. Prepend it with @ to allow parsing as DateTime
|
||||
$cachedLastModified = new \DateTimeImmutable((is_numeric($cachedLastModified) ? '@' : '') . $cachedLastModified);
|
||||
$config['if_not_modified_since'] = $cachedLastModified->getTimestamp();
|
||||
} catch (Exception $dateTimeParseFailue) {
|
||||
// Ignore invalid 'Last-Modified' HTTP header value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue