summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Wunderer <robert.wunderer@caprisys.at>2023-02-24 08:16:45 +0000
committerBenjamin Brahmer <info@b-brahmer.de>2023-03-23 12:12:06 +0100
commiteeabb4189b2376e1c5cb6fdeaa908bb30bfd1584 (patch)
treeee9a6408ec71499f5ccee6d15e662531beb43f21
parentbe95c17f46cb689a41db9d1b3d15543710c74ab7 (diff)
Use httpLastModified field for If-Modified-Since header when fetching feed updates
Signed-off-by: Robert Wunderer <robert.wunderer@caprisys.at>
-rw-r--r--CHANGELOG.md1
-rwxr-xr-xlib/Fetcher/FeedFetcher.php10
-rw-r--r--lib/Fetcher/IFeedFetcher.php3
-rw-r--r--lib/Service/FeedServiceV2.php3
4 files changed, 13 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 01ca3c80d..5930ea915 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@ The format is mostly based on [Keep a Changelog](https://keepachangelog.com/en/1
### Changed
### Fixed
+- Use httpLastModified field for If-Modified-Since header when fetching feed updates
# Releases
## [21.1.0] - 2023-03-20
diff --git a/lib/Fetcher/FeedFetcher.php b/lib/Fetcher/FeedFetcher.php
index 8864df084..60d798889 100755
--- a/lib/Fetcher/FeedFetcher.php
+++ b/lib/Fetcher/FeedFetcher.php
@@ -114,15 +114,21 @@ class FeedFetcher implements IFeedFetcher
string $url,
bool $fullTextEnabled,
?string $user,
- ?string $password
+ ?string $password,
+ ?string $httpLastModified
): array {
$url2 = new Net_URL2($url);
if (!is_null($user) && trim($user) !== '') {
$url2->setUserinfo(rawurlencode($user), rawurlencode($password));
}
+ if (!is_null($httpLastModified) && trim($httpLastModified) !== '') {
+ $lastModified = new DateTime($httpLastModified);
+ } else {
+ $lastModified = null;
+ }
$url = $url2->getNormalizedURL();
$this->reader->resetFilters();
- $resource = $this->reader->read($url);
+ $resource = $this->reader->read($url, null, $lastModified);
$location = $resource->getUrl();
$parsedFeed = $resource->getFeed();
diff --git a/lib/Fetcher/IFeedFetcher.php b/lib/Fetcher/IFeedFetcher.php
index 45e0915f0..8729858b5 100644
--- a/lib/Fetcher/IFeedFetcher.php
+++ b/lib/Fetcher/IFeedFetcher.php
@@ -37,7 +37,8 @@ interface IFeedFetcher
string $url,
bool $fullTextEnabled,
?string $user,
- ?string $password
+ ?string $password,
+ ?string $httpLastModified
): array;
/**
diff --git a/lib/Service/FeedServiceV2.php b/lib/Service/FeedServiceV2.php
index 3e02b3971..3610c3e3a 100644
--- a/lib/Service/FeedServiceV2.php
+++ b/lib/Service/FeedServiceV2.php
@@ -267,7 +267,8 @@ class FeedServiceV2 extends Service
$location,
$feed->getFullTextEnabled(),
$feed->getBasicAuthUser(),
- $feed->getBasicAuthPassword()
+ $feed->getBasicAuthPassword(),
+ $feed->getHttpLastModified()
);
} catch (ReadErrorException $ex) {
$feed->setUpdateErrorCount($feed->getUpdateErrorCount() + 1);