summaryrefslogtreecommitdiffstats
path: root/src/afb-hreq.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-05-23 16:26:13 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-05-23 16:26:13 +0200
commit83b48bb7331232020068d537716435458786a0cd (patch)
tree6dccea48b59327a819ad8a762e48ea0f81a9d4fe /src/afb-hreq.c
parentfca2e14e1d57d7b89d1a6de07075cc0e6e157ca7 (diff)
fix unicity of returned reqid
Change-Id: Ib6c56844312112cc20e2c930f5803d620a9cbafc Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-hreq.c')
-rw-r--r--src/afb-hreq.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/afb-hreq.c b/src/afb-hreq.c
index 35b90aac..8c5110d9 100644
--- a/src/afb-hreq.c
+++ b/src/afb-hreq.c
@@ -691,14 +691,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);