X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-hsrv.c;h=7e680cc479fe6edadbe29b32189f66cf80c2c627;hb=870652219335d54099ba67b721164b456b7975e9;hp=3bca5839c7caa6ef54fe837ded2ca479fc21624d;hpb=7bf0d9c6f807ffae6d9871c606afeccb9b478d3d;p=src%2Fapp-framework-binder.git diff --git a/src/afb-hsrv.c b/src/afb-hsrv.c index 3bca5839..7e680cc4 100644 --- a/src/afb-hsrv.c +++ b/src/afb-hsrv.c @@ -109,6 +109,7 @@ static int access_handler( struct afb_hsrv *hsrv; struct hsrv_handler *iter; const char *type; + enum json_tokener_error jerr; hsrv = cls; hreq = *recordreq; @@ -179,12 +180,13 @@ static int access_handler( } } else if (hreq->tokener) { hreq->json = json_tokener_parse_ex(hreq->tokener, upload_data, (int)*upload_data_size); - switch (json_tokener_get_error(hreq->tokener)) { - case json_tokener_success: - case json_tokener_continue: - break; - default: - ERROR("error in POST json: %s", json_tokener_error_desc(json_tokener_get_error(hreq->tokener))); + 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; } @@ -263,7 +265,7 @@ static void do_run(int signum, void *arg) fdev_set_events(hsrv->fdev, EPOLLIN); } -void run_micro_httpd(struct afb_hsrv *hsrv) +void afb_hsrv_run(struct afb_hsrv *hsrv) { fdev_set_events(hsrv->fdev, 0); if (jobs_queue(hsrv, 0, do_run, hsrv) < 0) @@ -272,7 +274,7 @@ void run_micro_httpd(struct afb_hsrv *hsrv) static void listen_callback(void *hsrv, uint32_t revents, struct fdev *fdev) { - run_micro_httpd(hsrv); + afb_hsrv_run(hsrv); } static int new_client_handler(void *cls, const struct sockaddr *addr, socklen_t addrlen)