json-rpc-test-server: make sure to set the id in responses

This commit is contained in:
Přemysl Eric Janouch 2020-09-01 20:55:22 +02:00
parent f6225ac6cc
commit 20558ecd2b
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 5 additions and 0 deletions

View File

@ -1428,6 +1428,8 @@ end:
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/// Handlers must not set the `id` field in their responses, that will be filled
/// in automatically according to whether the request is a notification or not.
typedef json_t *(*json_rpc_handler_fn) (struct server_context *, json_t *);
struct json_rpc_handler_info
@ -1493,7 +1495,10 @@ process_json_rpc_request (struct server_context *ctx, json_t *request)
json_t *response = handler->handler (ctx, params);
if (id)
{
(void) json_object_set (response, "id", id);
return response;
}
// Notifications don't get responses
json_decref (response);