diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2019-05-10 17:15:00 +0200 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2019-05-10 17:15:00 +0200 |
commit | 1159bc3c24f1354859a28e642292c090267b856f (patch) | |
tree | b4c7c3cf2e4b2087cbc2241c833001e32ef6c3a4 | |
parent | 730cc0c1a80c7ba10b6a117102b173ca58f4b11e (diff) | |
download | twister-1159bc3c24f1354859a28e642292c090267b856f.tar.gz twister-1159bc3c24f1354859a28e642292c090267b856f.tar.bz2 twister-1159bc3c24f1354859a28e642292c090267b856f.zip |
Decompress requests.
-rw-r--r-- | src/twister/Makefile.am | 1 | ||||
-rw-r--r-- | src/twister/taler-twister-service.c | 46 |
2 files changed, 34 insertions, 13 deletions
diff --git a/src/twister/Makefile.am b/src/twister/Makefile.am index cf03d1a..411e19d 100644 --- a/src/twister/Makefile.am +++ b/src/twister/Makefile.am @@ -18,6 +18,7 @@ taler_twister_service_LDADD = \ -lcurl \ -ljansson \ -lgnunetutil \ + -lgnunetjson \ -lz taler_twister_SOURCES = taler-twister.c diff --git a/src/twister/taler-twister-service.c b/src/twister/taler-twister-service.c index 12b96ab..0552495 100644 --- a/src/twister/taler-twister-service.c +++ b/src/twister/taler-twister-service.c @@ -35,6 +35,7 @@ #include <gnurl/curl.h> #endif #include <gnunet/gnunet_util_lib.h> +#include <gnunet/gnunet_json_lib.h> #include "twister.h" #include <jansson.h> #include <microhttpd.h> @@ -52,6 +53,8 @@ #endif +#define REQUEST_BUFFER_MAX (1024*1024) + /** * Log curl error. * @@ -370,9 +373,10 @@ run_mhd_now (void); /** - * Transform _one_ CURL header into MHD format and put it - * into the response headers list; mostly copies the headers, - * but makes special adjustments based on control requests. + * Transform _one_ CURL header (gotten from the request) into + * MHD format and put it into the response headers list; mostly + * copies the headers, but makes special adjustments based on + * control requests. * * @param buffer curl buffer with a single * line of header data; not 0-terminated! @@ -1407,10 +1411,17 @@ create_response (void *cls, if ('\0' != flip_path_ul[0]) { - hr->json = json_loadb (hr->io_buf, - hr->io_len, - JSON_REJECT_DUPLICATES, - NULL); + GNUNET_assert (0 == strcmp (MHD_HTTP_METHOD_POST, + meth)); + GNUNET_break + (GNUNET_JSON_PR_SUCCESS != GNUNET_JSON_post_parser + (REQUEST_BUFFER_MAX, + con, + con_cls, + hr->io_buf, + &hr->io_len, + &hr->json)); + flip_object (con, hr->json, flip_path_ul); @@ -1425,12 +1436,21 @@ create_response (void *cls, if ('\0' != modify_path_ul[0]) { - hr->json = json_loads (hr->io_buf, - JSON_REJECT_DUPLICATES, - NULL); + GNUNET_assert (0 == strcmp (MHD_HTTP_METHOD_POST, + meth)); + GNUNET_break + (GNUNET_JSON_PR_SUCCESS != GNUNET_JSON_post_parser + (REQUEST_BUFFER_MAX, + con, + con_cls, + hr->io_buf, + &hr->io_len, + &hr->json)); + modify_object (con, hr->json, modify_path_ul); + /* Existing io_len is enough to accomodate this encoding. */ json_dumpb (hr->json, hr->io_buf, @@ -1439,7 +1459,6 @@ create_response (void *cls, json_decref (hr->json); } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Generating curl request\n"); hr->curl = curl_easy_init (); @@ -1710,7 +1729,8 @@ create_response (void *cls, if (NULL != hr->json) { GNUNET_free (hr->io_buf); - hr->io_buf = json_dumps (hr->json, JSON_COMPACT); + hr->io_buf = json_dumps (hr->json, + JSON_COMPACT); hr->io_len = strlen (hr->io_buf); json_decref (hr->json); } @@ -1728,7 +1748,7 @@ create_response (void *cls, } /** - * COMPRESSION STARTS HERE (hr->io_buf/len is data). + * COMPRESSION STARTS HERE. */ if (GNUNET_YES == hr->deflate) GNUNET_assert |