summaryrefslogtreecommitdiff
path: root/httpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'httpd.c')
-rw-r--r--httpd.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/httpd.c b/httpd.c
index 79d489f..70083a1 100644
--- a/httpd.c
+++ b/httpd.c
@@ -266,6 +266,16 @@ void httpd_connection(FILE *f)
srv_archive("RECV", NULL, req, payload, p_size, status, headers, body, b_size);
+ /* JSON validation check */
+ if (strcmp(ctype, "application/json") == 0) {
+ xs *j = xs_json_loads(body);
+
+ if (j == NULL) {
+ srv_log(xs_fmt("bad JSON"));
+ srv_archive_error("bad_json", "bad JSON", req, body);
+ }
+ }
+
xs_free(body);
}