X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-hreq.c;h=4239670de8149a5b74ea09fb35972539096a277f;hb=9d59db317f2ac51c3eb058fe740bd39b3021fbcd;hp=35b90aace757b08220ec02b2a9a5d5ad310090d0;hpb=c20a2d779c32a4c0580a99e2cda2c3c6bc6156f3;p=src%2Fapp-framework-binder.git diff --git a/src/afb-hreq.c b/src/afb-hreq.c index 35b90aac..4239670d 100644 --- a/src/afb-hreq.c +++ b/src/afb-hreq.c @@ -611,6 +611,7 @@ struct afb_req afb_hreq_to_req(struct afb_hreq *hreq) static struct afb_arg req_get(struct afb_hreq *hreq, const char *name) { + const char *value; struct hreq_data *hdat = get_data(hreq, name, 0); if (hdat) return (struct afb_arg){ @@ -618,10 +619,11 @@ static struct afb_arg req_get(struct afb_hreq *hreq, const char *name) .value = hdat->value, .path = hdat->path }; - + + value = MHD_lookup_connection_value(hreq->connection, MHD_GET_ARGUMENT_KIND, name); return (struct afb_arg){ - .name = name, - .value = MHD_lookup_connection_value(hreq->connection, MHD_GET_ARGUMENT_KIND, name), + .name = value == NULL ? NULL : name, + .value = value, .path = NULL }; } @@ -691,14 +693,10 @@ static void req_reply(struct afb_hreq *hreq, unsigned retcode, const char *statu reply = afb_msg_json_reply(status, info, resp, token, uuid); reqid = afb_hreq_get_argument(hreq, long_key_for_reqid); - if (reqid != NULL && json_object_object_get_ex(reply, "request", &request)) { - json_object_object_add (request, long_key_for_reqid, json_object_new_string(reqid)); - } else { + if (reqid == NULL) reqid = afb_hreq_get_argument(hreq, short_key_for_reqid); - if (reqid != NULL && json_object_object_get_ex(reply, "request", &request)) { - json_object_object_add (request, short_key_for_reqid, json_object_new_string(reqid)); - } - } + if (reqid != NULL && json_object_object_get_ex(reply, "request", &request)) + json_object_object_add (request, short_key_for_reqid, json_object_new_string(reqid)); response = MHD_create_response_from_callback((uint64_t)strlen(json_object_to_json_string(reply)), SIZE_RESPONSE_BUFFER, (void*)send_json_cb, reply, (void*)json_object_put); afb_hreq_reply(hreq, retcode, response, NULL);