diff options
Diffstat (limited to 'src/testing/testing_api_cmd_testserver.c')
-rw-r--r-- | src/testing/testing_api_cmd_testserver.c | 59 |
1 files changed, 40 insertions, 19 deletions
diff --git a/src/testing/testing_api_cmd_testserver.c b/src/testing/testing_api_cmd_testserver.c index d06ce824..c5a929c0 100644 --- a/src/testing/testing_api_cmd_testserver.c +++ b/src/testing/testing_api_cmd_testserver.c @@ -73,7 +73,7 @@ struct RequestCtx /** * body of the webhook. */ - char *body; + void *body; /** * size of the body @@ -136,7 +136,6 @@ handler_cb (void *cls, { struct TestserverState *ts = cls; struct RequestCtx *rc = *con_cls; - json_t *body; (void) version; if (NULL == rc) @@ -165,12 +164,14 @@ handler_cb (void *cls, if (0 == strcasecmp (method, MHD_HTTP_METHOD_GET)) { - body = GNUNET_JSON_PACK ( + json_t *reply; + + reply = GNUNET_JSON_PACK ( GNUNET_JSON_pack_string ( "status", "success")); return TALER_MHD_reply_json_steal (connection, - body, + reply, MHD_HTTP_OK); } if (0 != strcasecmp (method, @@ -181,19 +182,35 @@ handler_cb (void *cls, } if (0 != *upload_data_size) { - rc->body = GNUNET_strdup(upload_data); + void *body; + + body = GNUNET_malloc (rc->body_size + *upload_data_size); + memcpy (body, + rc->body, + rc->body_size); + GNUNET_free (rc->body); + memcpy (body + rc->body_size, + upload_data, + *upload_data_size); + rc->body = body; + rc->body_size += *upload_data_size; *upload_data_size = 0; GNUNET_array_append (ts->rcs, ts->rcs_length, rc); return MHD_YES; } - body = GNUNET_JSON_PACK ( - GNUNET_JSON_pack_string ("something", - "good")); - return TALER_MHD_reply_json_steal (connection, - body, - MHD_HTTP_OK); + + { + json_t *reply; + + reply = GNUNET_JSON_PACK ( + GNUNET_JSON_pack_string ("something", + "good")); + return TALER_MHD_reply_json_steal (connection, + reply, + MHD_HTTP_OK); + } } @@ -259,7 +276,7 @@ testserver_cleanup (void *cls, struct TestserverState *ser = cls; (void) cmd; - for (unsigned int i=0;i<ser->rcs_length-1;i++) + for (unsigned int i = 0; i<ser->rcs_length - 1; i++) { struct RequestCtx *rc = ser->rcs[i]; @@ -295,15 +312,19 @@ traits_testserver (void *cls, { struct RequestCtx *rc = ser->rcs[index]; struct TALER_TESTING_Trait traits[] = { - TALER_TESTING_make_trait_urls (index, &rc->url), - TALER_TESTING_make_trait_http_methods (index, &rc->http_method), - TALER_TESTING_make_trait_http_header (index, &rc->header), - TALER_TESTING_make_trait_http_body (index, &rc->body), + TALER_TESTING_make_trait_urls (index, + &rc->url), + TALER_TESTING_make_trait_http_methods (index, + &rc->http_method), + TALER_TESTING_make_trait_http_header (index, + &rc->header), + TALER_TESTING_make_trait_http_body (index, + &rc->body), + TALER_TESTING_make_trait_http_body_size (index, + &rc->body_size), TALER_TESTING_trait_end (), }; - fprintf (stdout, "\n\nbody %s\n\n", rc->body); - return TALER_TESTING_get_trait (traits, ret, trait, @@ -311,6 +332,7 @@ traits_testserver (void *cls, } } + /** * This function is used to start the web server. * @@ -340,4 +362,3 @@ TALER_TESTING_cmd_testserver (const char *label, /* end of testing_api_cmd_checkserver.c */ - |