diff --git a/src/document.cpp b/src/document.cpp index 81b30cb..e53f33b 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -259,11 +260,23 @@ string Document::remove_html(string html) const string Document::extract_location(const RestClient::HeaderFields &headers) const { - string location{headers.at("Location")}; - if (location.empty()) + string location; + try { - location = headers.at("location"); + location = headers.at("Location"); } + catch (const std::out_of_range &) + { + try + { + location = headers.at("location"); + } + catch (const std::out_of_range &) + { + throw std::runtime_error{"Could not extract new feed location."}; + } + } + return location; }