diff options
author | 2024-06-23 17:11:29 +0200 | |
---|---|---|
committer | 2024-09-14 21:00:22 +0300 | |
commit | e4f898bfb1e85cf1a532b139b3d73351484480b8 (patch) | |
tree | 69ca675866bfa051d02a4d796c448ff968db67e7 | |
parent | 6335e994b9e727e3228841e230b3675adab11501 (diff) | |
download | newsboat-e4f898bfb1e85cf1a532b139b3d73351484480b8.tar.gz newsboat-e4f898bfb1e85cf1a532b139b3d73351484480b8.tar.zst newsboat-e4f898bfb1e85cf1a532b139b3d73351484480b8.zip |
Don't retry feed retrieval on HTTP 304 (Not Modified)
(cherry picked from commit 10ef5b59fa16c9eedacf217550f408026bebbdc8)
-rw-r--r-- | rss/exception.h | 3 | ||||
-rw-r--r-- | rss/parser.cpp | 3 | ||||
-rw-r--r-- | src/reloader.cpp | 5 |
3 files changed, 10 insertions, 1 deletions
diff --git a/rss/exception.h b/rss/exception.h index 5b0548e2f..1fc1ef33 100644 --- a/rss/exception.h +++ b/rss/exception.h @@ -16,6 +16,9 @@ private: std::string emsg; }; +class NotModifiedException : public std::exception { +}; + } // namespace rsspp #endif /* NEWSBOAT_RSSPPEXCEPTION_H_ */ diff --git a/rss/parser.cpp b/rss/parser.cpp index 8bae6e75..9092acc1 100644 --- a/rss/parser.cpp +++ b/rss/parser.cpp @@ -239,6 +239,9 @@ Feed Parser::parse_url(const std::string& url, } throw Exception(msg); } + if (infoOk == CURLE_OK && status == 304) { + throw NotModifiedException(); + } LOG(Level::INFO, "Parser::parse_url: retrieved data for %s: %s", diff --git a/src/reloader.cpp b/src/reloader.cpp index 71b8c0ac..491494a4 100644 --- a/src/reloader.cpp +++ b/src/reloader.cpp @@ -132,11 +132,14 @@ void Reloader::reload(unsigned int pos, _("Error while retrieving %s: %s"), utils::censor_url(oldfeed->rssurl()), emsg); - } catch (rsspp::Exception& e) { + } catch (const rsspp::Exception& e) { errmsg = strprintf::fmt( _("Error while retrieving %s: %s"), utils::censor_url(oldfeed->rssurl()), e.what()); + } catch (const rsspp::NotModifiedException&) { + // Nothing to be done, feed was not chaned since last retrieve + oldfeed->set_status(DlStatus::SUCCESS); } if (!errmsg.empty()) { oldfeed->set_status(DlStatus::DL_ERROR); |