http api请求有json body才解析

This commit is contained in:
xia-chu 2026-02-25 12:21:43 +08:00
parent 0ead9b6945
commit 725fdf1786

View File

@ -225,6 +225,7 @@ ApiArgsType getAllArgs(const Parser &parser) {
allArgs[pr.first] = strCoding::UrlDecodeComponent(pr.second); allArgs[pr.first] = strCoding::UrlDecodeComponent(pr.second);
} }
} else if (parser["Content-Type"].find("application/json") == 0) { } else if (parser["Content-Type"].find("application/json") == 0) {
if (!parser.content().empty()) {
try { try {
stringstream ss(parser.content()); stringstream ss(parser.content());
Value jsonArgs; Value jsonArgs;
@ -236,6 +237,7 @@ ApiArgsType getAllArgs(const Parser &parser) {
} catch (std::exception &ex) { } catch (std::exception &ex) {
WarnL << ex.what(); WarnL << ex.what();
} }
}
} else if (!parser["Content-Type"].empty()) { } else if (!parser["Content-Type"].empty()) {
WarnL << "invalid Content-Type:" << parser["Content-Type"]; WarnL << "invalid Content-Type:" << parser["Content-Type"];
} }