gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-twister] branch master updated: Decompress requests.


From: gnunet
Subject: [GNUnet-SVN] [taler-twister] branch master updated: Decompress requests.
Date: Fri, 10 May 2019 17:15:46 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository twister.

The following commit(s) were added to refs/heads/master by this push:
     new 1159bc3  Decompress requests.
1159bc3 is described below

commit 1159bc3c24f1354859a28e642292c090267b856f
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri May 10 17:15:00 2019 +0200

    Decompress requests.
---
 src/twister/Makefile.am             |  1 +
 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

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]