Skip to content

Commit c50a510

Browse files
authored
server: refactor: clean up http code (#5912)
1 parent 3166ccf commit c50a510

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

examples/server/server.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2945,7 +2945,7 @@ int main(int argc, char ** argv) {
29452945
if (!result.error && result.stop) {
29462946
res.set_content(result.data.dump(-1, ' ', false, json::error_handler_t::replace), "application/json; charset=utf-8");
29472947
} else {
2948-
res.status = 404;
2948+
res.status = 400;
29492949
res.set_content(result.data["content"], "text/plain; charset=utf-8");
29502950
}
29512951

@@ -3202,6 +3202,7 @@ int main(int argc, char ** argv) {
32023202
svr.Post("/embedding", [&params, &llama](const httplib::Request & req, httplib::Response & res) {
32033203
res.set_header("Access-Control-Allow-Origin", req.get_header_value("Origin"));
32043204
if (!params.embedding) {
3205+
res.status = 400;
32053206
res.set_content("This server does not support embeddings. Start it with `--embeddings`", "text/plain; charset=utf-8");
32063207
return;
32073208
}
@@ -3232,6 +3233,7 @@ int main(int argc, char ** argv) {
32323233
svr.Post("/v1/embeddings", [&params, &llama](const httplib::Request & req, httplib::Response & res) {
32333234
res.set_header("Access-Control-Allow-Origin", req.get_header_value("Origin"));
32343235
if (!params.embedding) {
3236+
res.status = 400;
32353237
res.set_content("This server does not support embeddings. Start it with `--embeddings`", "text/plain; charset=utf-8");
32363238
return;
32373239
}

0 commit comments

Comments
 (0)