From eeabb4189b2376e1c5cb6fdeaa908bb30bfd1584 Mon Sep 17 00:00:00 2001 From: Robert Wunderer Date: Fri, 24 Feb 2023 08:16:45 +0000 Subject: Use httpLastModified field for If-Modified-Since header when fetching feed updates Signed-off-by: Robert Wunderer --- lib/Fetcher/FeedFetcher.php | 10 ++++++++-- lib/Fetcher/IFeedFetcher.php | 3 ++- lib/Service/FeedServiceV2.php | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'lib') 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); -- cgit v1.2.3