wsd: tolerate missing FinishedCallback in http::Response

And explain the use of linear search in header().

Change-Id: If6c39bffa738861d0c86684f9560ed6e4a6970e1
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
This commit is contained in:
Ashod Nakashian 2021-03-20 19:44:38 -04:00 committed by Ashod Nakashian
parent 69436ed0f3
commit 725a3070c3

View file

@ -306,6 +306,9 @@ public:
std::string get(const std::string& key) const
{
// There are typically half a dozen header
// entries, rarely much more. A map would
// probably not be faster but would add complexity.
for (const auto& pair : _headers)
{
if (pair.first == key)
@ -761,7 +764,8 @@ private:
LOG_TRC("Finishing");
_bodyFile.close();
_state = newState;
_finishedCallback();
if (_finishedCallback)
_finishedCallback();
}
}