- if (!MHD_post_process (hreq->postform, upload_data, *upload_data_size))
- goto internal_error;
- } else {
- if (!afb_hreq_post_add(hreq, "", upload_data, *upload_data_size))
- goto internal_error;
+ if (!MHD_post_process (hreq->postform, upload_data, *upload_data_size)) {
+ ERROR("error in POST processor");
+ afb_hreq_reply_error(hreq, MHD_HTTP_INTERNAL_SERVER_ERROR);
+ return MHD_YES;
+ }
+ } else if (hreq->tokener) {
+ hreq->json = json_tokener_parse_ex(hreq->tokener, upload_data, (int)*upload_data_size);
+ jerr = json_tokener_get_error(hreq->tokener);
+ if (jerr == json_tokener_continue) {
+ hreq->json = json_tokener_parse_ex(hreq->tokener, "", 1);
+ jerr = json_tokener_get_error(hreq->tokener);
+ }
+ if (jerr != json_tokener_success) {
+ ERROR("error in POST json: %s", json_tokener_error_desc(jerr));
+ afb_hreq_reply_error(hreq, MHD_HTTP_BAD_REQUEST);
+ return MHD_YES;
+ }