- } else {
- if (!afb_hreq_post_add(hreq, "", upload_data, *upload_data_size)) {
- afb_hreq_reply_error(hreq, MHD_HTTP_INTERNAL_SERVER_ERROR);
+ } 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);