twister

HTTP fault injector for testing
Log | Files | Refs | README | LICENSE

commit 88ae598d1787b54e460dbf00edbe3b9e6df64620
parent 726e1c9b1d4bb50e0b13be3a0e527a37032dc1e5
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date:   Thu, 17 May 2018 00:43:37 +0200

reuse internal json to encode/decode upload data.

Diffstat:
Msrc/twister/taler-twister-service.c | 22+++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/twister/taler-twister-service.c b/src/twister/taler-twister-service.c @@ -153,7 +153,7 @@ struct HttpRequest char *url; /** - * Response's JSON. + * JSON we use to parse payloads (in both directions). */ json_t *json; @@ -494,6 +494,9 @@ create_mhd_response_from_hr (struct HttpRequest *hr) (unsigned int) resp_code); hr->response_code = resp_code; + + /* Note, will be NULL if io_buf does not represent + * a JSON value. */ hr->json = json_loadb (hr->io_buf, hr->io_len, JSON_DECODE_ANY, @@ -1252,23 +1255,24 @@ create_response (void *cls, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Going to modify the upload object (%s)\n", hr->io_buf); - json_t *tmp; - tmp = json_loads (hr->io_buf, - JSON_REJECT_DUPLICATES, - NULL); + + hr->json = json_loads (hr->io_buf, + JSON_REJECT_DUPLICATES, + NULL); flip_object (con, - tmp, + hr->json, flip_path_ul); - json_dumpb (tmp, + json_dumpb (hr->json, hr->io_buf, - hr->io_len, /* Existing io_len is enough to accomodate this encoding. */ +/* Existing io_len is enough to accomodate this encoding. */ + hr->io_len, JSON_COMPACT); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Flipped (?) upload object (%s)\n", hr->io_buf); - json_decref (tmp); + json_decref (hr->json); } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,