From 6b33ffc5e589c4d3bca1656758db6442e1595b32 Mon Sep 17 00:00:00 2001 From: Gulliver Date: Thu, 2 Jan 2025 12:35:17 +0100 Subject: [PATCH] replaced += by append and changed the order of strings to remove necessitity to substring at the the end. --- include/crow/routing.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/crow/routing.h b/include/crow/routing.h index 26690a50a..546e59bb1 100644 --- a/include/crow/routing.h +++ b/include/crow/routing.h @@ -1574,7 +1574,7 @@ namespace crow // NOTE: Already documented in "crow/app.h" } else if (req.method == HTTPMethod::Options) { - std::string allow = "OPTIONS, HEAD, "; + std::string allow = "OPTIONS, HEAD"; if (req.url == "/*") { @@ -1585,10 +1585,10 @@ namespace crow // NOTE: Already documented in "crow/app.h" if (!per_methods_[i].trie.is_empty()) { - allow += method_name(static_cast(i)) + ", "; + allow.append(", "); + allow.append(method_name(static_cast(i))); } } - allow = allow.substr(0, allow.size() - 2); res = response(204); res.set_header("Allow", allow); res.end(); @@ -1607,12 +1607,12 @@ namespace crow // NOTE: Already documented in "crow/app.h" if (static_cast(HTTPMethod::Head) == i) continue; // HEAD is always allowed - allow += method_name(static_cast(i)) + ", "; + allow.append(", "); + allow.append(method_name(static_cast(i))); } } if (rules_matched) { - allow = allow.substr(0, allow.size() - 2); res = response(204); res.set_header("Allow", allow); res.end();