gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-twister] 04/34: parsing proxied responses.


From: gnunet
Subject: [GNUnet-SVN] [taler-twister] 04/34: parsing proxied responses.
Date: Sat, 17 Mar 2018 01:57:55 +0100

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

marcello pushed a commit to branch master
in repository twister.

commit fd60998bfd51e90904449d2a65c5fd4d3381a747
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Mar 6 17:47:16 2018 +0100

    parsing proxied responses.
    
    Twister recognizes the -d option, and attempts
    to parse the response body it got from the proxied
    service.
---
 src/test/test_twister.sh            | 10 +++++-----
 src/twister/taler-twister-service.c | 35 +++++++++++++++++------------------
 2 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/src/test/test_twister.sh b/src/test/test_twister.sh
index f7d278f..8824b35 100755
--- a/src/test/test_twister.sh
+++ b/src/test/test_twister.sh
@@ -1,7 +1,5 @@
 #!/bin/sh
 
-# Steps:
-
 # Launch the Web server.
 ./test_twister_webserver &
 web_server_pid=$!
@@ -10,18 +8,20 @@ web_server_pid=$!
 taler-twister-service -c ./test_twister.conf &
 twister_service_pid=$!
 
-# Use the Twister-APIs to hack the response code.
+# hack the response code.
 taler-twister -c ./test_twister.conf --responsecode 202
 
-# 4) Use curl to GET /something
 status_code=$(curl -s http://localhost:8888/ -o /dev/null \
   -w "%{http_code}")
 
+# delete uploaded (inner) object.
+taler-twister -c ./test_twister.conf -d "f0.0.f1"
+
 # shutdown twister and webserver
 kill $web_server_pid
 kill $twister_service_pid
 
-# check status code has been hacked
+# check status code was hacked
 if ! test 202 = $status_code; then
   echo "Response code has not been hacked."
   exit 1
diff --git a/src/twister/taler-twister-service.c 
b/src/twister/taler-twister-service.c
index 07d703f..6af830e 100644
--- a/src/twister/taler-twister-service.c
+++ b/src/twister/taler-twister-service.c
@@ -193,8 +193,8 @@ struct HttpRequest
  * proxied service.  FIXME: define Taler-compatible error codes
  * and messages..
  */
-static char *error_msg = "{\"error\": \
-  \"Failed to parse proxied response\"}";
+static char *error_msg = "{\"error\":" \
+" \"Failed to parse proxied response\"}";
 
 /**
  * The cURL download task (curl multi API).
@@ -1092,9 +1092,8 @@ create_response (void *cls,
 
     MHD_destroy_response (hr->response);
 
-    if (NULL == MHD_lookup_connection_value (con,
-                                             MHD_HEADER_KIND,
-                                             "application/json"))
+    if (NULL == MHD_lookup_connection_value
+        (con, MHD_HEADER_KIND, "application/json"))
       /* No JSON header, but will try to parse it anyway. */
       TALER_LOG_WARNING ("Response is not a JSON (?)\n");
 
@@ -1102,23 +1101,22 @@ create_response (void *cls,
       (hr->io_buf, hr->io_len, JSON_DECODE_ANY, &error)))
     {
       TALER_LOG_ERROR ("Could not parse response\n");
-      hr->response = MHD_create_response_from_buffer
-        (strlen (error_msg),
-         error_msg,
-         MHD_RESPMEM_PERSISTENT);
+      mod_response = error_msg;
       /* Need a code that doesn't clash with Taler's. */
       hr->response_code = MHD_HTTP_GONE;
     }
-  
-    GNUNET_assert (NULL != strtok (delete_path, "."));
-    while (NULL != (token_path = strtok (NULL, ".")))
+    else
     {
-      /* fill with logic */
+      GNUNET_assert (NULL != strtok (delete_path, "."));
+      while (NULL != (token_path = strtok (NULL, ".")))
+      {
+        /* fill with logic */
     
-    }
+      }
 
-    mod_response = json_dumps (parsed_response, JSON_COMPACT);
-    json_decref (parsed_response);
+      mod_response = json_dumps (parsed_response, JSON_COMPACT);
+      json_decref (parsed_response);
+    }
 
     hr->response = MHD_create_response_from_buffer
       (strlen (mod_response),
@@ -1267,8 +1265,9 @@ do_httpd (void *cls);
 
 /**
  * Schedule MHD.  This function should be called initially when an
- * MHD is first getting its client socket, and will then automatically
- * always be called later whenever there is work to be done.
+ * MHD is first getting its client socket, and will then
+ * automatically always be called later whenever there is work to
+ * be done.
  */
 static void
 schedule_httpd (void)

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



reply via email to

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