diff --git a/include/crow/multipart.h b/include/crow/multipart.h index 24040c962..ae2cdc189 100644 --- a/include/crow/multipart.h +++ b/include/crow/multipart.h @@ -175,10 +175,19 @@ namespace crow return std::string(); } + // cpp17(cpp 20 have) does not have ends_with, so we need to implement it ourselves + bool ends_with(const std::string& str, const std::string& suffix) { + if (suffix.size() > str.size()) return false; + return std::equal(suffix.rbegin(), suffix.rend(), str.rbegin()); + } + void parse_body(std::string body) { std::string delimiter = dd + boundary; - + if(!ends_with(body, crlf)) + { + body += crlf; + } // TODO(EDev): Exit on error while (body != (crlf)) {