Skip to content

Commit 9d0865d

Browse files
committed
Send 403 and 404 error codes
1 parent 30294b8 commit 9d0865d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/mg_rpc_channel_http.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ static bool mg_rpc_channel_http_send_frame(struct mg_rpc_channel *ch,
211211
struct json_token error_tok = JSON_INVALID_TOKEN;
212212
json_scanf(f.p, f.len, "{result: %T, error: %T}", &result_tok, &error_tok);
213213
if (error_tok.len != 0) {
214-
code = 500;
214+
int error_code = 0;
215+
json_scanf(error_tok.ptr, error_tok.len, "{code: %d}", &error_code);
216+
code = (error_code == 403 ? 403 : (error_code == 404 ? 404 : 500));
215217
body = mg_mk_str_n(error_tok.ptr, error_tok.len);
216218
} else {
217219
body = mg_mk_str_n(result_tok.ptr, result_tok.len);

0 commit comments

Comments
 (0)