X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-hsrv.c;h=685c55b853a7b192c38f7f239c14c039d5831767;hb=a868fc272224cc8737e2925aa5cc94f0dd0bc8d6;hp=efa74f4b4443f3424c6a1e6aa7177ca26fc83263;hpb=93d8d6f69399dacbb43c0780ebccc378b4f44880;p=src%2Fapp-framework-binder.git diff --git a/src/afb-hsrv.c b/src/afb-hsrv.c index efa74f4b..685c55b8 100644 --- a/src/afb-hsrv.c +++ b/src/afb-hsrv.c @@ -29,6 +29,9 @@ #include #include +#if MHD_VERSION < 0x00095206 +# define MHD_ALLOW_SUSPEND_RESUME MHD_USE_SUSPEND_RESUME +#endif #include "afb-method.h" #include "afb-context.h" @@ -109,6 +112,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 +183,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; } @@ -235,7 +240,7 @@ static int access_handler( } /* no handler */ - WARNING("Unhandled request to %s", hreq->url); + NOTICE("Unhandled request to %s", hreq->url); afb_hreq_reply_error(hreq, MHD_HTTP_NOT_FOUND); return MHD_YES; } @@ -415,7 +420,7 @@ int afb_hsrv_start(struct afb_hsrv *hsrv, uint16_t port, unsigned int connection const union MHD_DaemonInfo *info; httpd = MHD_start_daemon( - MHD_USE_EPOLL | MHD_ALLOW_UPGRADE | MHD_USE_TCP_FASTOPEN | MHD_USE_DEBUG | MHD_USE_SUSPEND_RESUME, + MHD_USE_EPOLL | MHD_ALLOW_UPGRADE | MHD_USE_TCP_FASTOPEN | MHD_USE_DEBUG | MHD_ALLOW_SUSPEND_RESUME, port, /* port */ new_client_handler, NULL, /* Tcp Accept call back + extra attribute */ access_handler, hsrv, /* Http Request Call back + extra attribute */