mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-02-16 23:29:56 +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) {
|
if ($cachedResponse) {
|
||||||
$cachedLastModified = $cachedResponse->getHeader('last-modified');
|
$cachedLastModified = $cachedResponse->getHeader('last-modified');
|
||||||
if ($cachedLastModified) {
|
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();
|
$config['if_not_modified_since'] = $cachedLastModified->getTimestamp();
|
||||||
|
} catch (Exception $dateTimeParseFailue) {
|
||||||
|
// Ignore invalid 'Last-Modified' HTTP header value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue