diff options
author | 2024-06-23 17:11:29 +0200 | |
---|---|---|
committer | 2024-09-14 20:51:30 +0300 | |
commit | 2284415e510935bb1937fc06a1ab3b8bd44cf3c8 (patch) | |
tree | e6898927f11e3dcb02c025da0b48f6b096b50064 | |
parent | 5e71f20e236f939610acccc047e64dceb902f689 (diff) | |
download | newsboat-2284415e510935bb1937fc06a1ab3b8bd44cf3c8.tar.gz newsboat-2284415e510935bb1937fc06a1ab3b8bd44cf3c8.tar.zst newsboat-2284415e510935bb1937fc06a1ab3b8bd44cf3c8.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 dfe72f3c..3afffe14 100644 --- a/rss/parser.cpp +++ b/rss/parser.cpp @@ -230,6 +230,9 @@ Feed Parser::parse_url(const std::string& url, } throw Exception(msg); } + if (infoOk == CURLE_OK && status == 304) { + throw NotModifiedException(); + } const std::string buf = curlDataReceiver->get_data(); LOG(Level::DEBUG, diff --git a/src/reloader.cpp b/src/reloader.cpp index 7f75a25d..ca26007b 100644 --- a/src/reloader.cpp +++ b/src/reloader.cpp @@ -142,11 +142,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); |