summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Dennis van der Schagt <dennisschagt@gmail.com> 2024-06-23 17:11:29 +0200
committerGravatar Alexander Batischev <eual.jp@gmail.com> 2024-09-21 16:43:55 +0300
commitc50ca9b7903233ab76a0316d439d853e11d57573 (patch)
treedcb70f761987ddc63080984594c5c1f9b307b936
parentdc3757aae9aa78323465caa5dc74f29325e0ab3f (diff)
downloadnewsboat-c50ca9b7903233ab76a0316d439d853e11d57573.tar.gz
newsboat-c50ca9b7903233ab76a0316d439d853e11d57573.tar.zst
newsboat-c50ca9b7903233ab76a0316d439d853e11d57573.zip
Don't retry feed retrieval on HTTP 304 (Not Modified)
(cherry picked from commit 10ef5b59fa16c9eedacf217550f408026bebbdc8)
-rw-r--r--rss/exception.h3
-rw-r--r--rss/parser.cpp3
-rw-r--r--src/reloader.cpp5
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 68b3c2ab..2eb66d82 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 3c11628d..9c5044a7 100644
--- a/src/reloader.cpp
+++ b/src/reloader.cpp
@@ -114,11 +114,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);