[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
- [GNUnet-SVN] [taler-twister] branch master updated (3513119 -> f717a7a), gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 11/34: fix double destruction of response., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 01/34: fix cli arg, gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 05/34: fix iteration over object path's parts., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 09/34: help string, gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 08/34: lazy check object/array path element., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 10/34: fix object walking., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 04/34: parsing proxied responses.,
gnunet <=
- [GNUnet-SVN] [taler-twister] 06/34: helper function., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 15/34: testing empty-object feature., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 03/34: get path parsing to compile., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 07/34: fix actual object emptying., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 13/34: conditional delete., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 30/34: body malformation test CMD., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 14/34: logging, gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 12/34: test command to empty objects., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 16/34: fix proxied response headers., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 17/34: moving object-killer into helper function., gnunet, 2018/03/16