Make Document::extract_location() more robust.
continuous-integration/drone/push Build was killed Details

This commit is contained in:
tastytea 2020-08-24 18:14:12 +02:00
parent c04ad4b4ab
commit e0c49c4702
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 16 additions and 3 deletions

View File

@ -29,6 +29,7 @@
#include <algorithm>
#include <fstream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <utility>
@ -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;
}