[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-twister] 16/34: fix proxied response headers.
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-twister] 16/34: fix proxied response headers. |
Date: |
Sat, 17 Mar 2018 01:58:07 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository twister.
commit b6b7f4616e7c933b3ed4520c64e8d281fb17f8d7
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Mar 8 15:01:16 2018 +0100
fix proxied response headers.
---
src/twister/taler-twister-service.c | 62 ++++++++++++++++++++-----------------
1 file changed, 34 insertions(+), 28 deletions(-)
diff --git a/src/twister/taler-twister-service.c
b/src/twister/taler-twister-service.c
index 929a087..d27257f 100644
--- a/src/twister/taler-twister-service.c
+++ b/src/twister/taler-twister-service.c
@@ -132,6 +132,11 @@ struct HttpRequest
char *io_buf;
/**
+ * Hold the response obtained by modifying the original one.
+ */
+ struct MHD_Response *mod_response;
+
+ /**
* MHD response object for this request.
*/
struct MHD_Response *response;
@@ -1066,15 +1071,13 @@ create_response (void *cls,
"Still waiting for response to be ready\n");
return MHD_YES;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Queueing response with MHD\n");
if (0 != hack_response_code)
{
hr->response_code = hack_response_code;
hack_response_code = 0; /* reset for next request */
}
- /* Empty the object pointed by `delete_path` only if
+ /* Empty the object pointed by `delete_path` ONLY IF
it is found within this response, otherwise it leaves
the response untouched. */
if ('\0' != delete_path[0])
@@ -1084,14 +1087,8 @@ create_response (void *cls,
json_t *cur;
json_error_t error;
char *token_path;
- char *mod_response;
+ char *mod_body;
unsigned int index;
- /* XXX: Who destroys the unused response? */
-
- 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 JSON (?)\n");
if (NULL == (parsed_response = json_loadb
(hr->io_buf, hr->io_len, JSON_DECODE_ANY, &error)))
@@ -1155,25 +1152,29 @@ create_response (void *cls,
hr->response);
}
- TALER_LOG_INFO ("Emptying object '%s'\n",
- json_dumps (element, JSON_COMPACT));
- mod_response = json_dumps (parsed_response, JSON_COMPACT);
-
- json_decref (parsed_response);
-
- /* We only reset once a empty-able object has
- been found. This way, it is possible to call this
- API way in advance respect to the response which
- is to be transformed. */
- delete_path[0] = '\0';
- json_decref (parsed_response);
- return MHD_queue_response
- (con, hr->response_code,
- MHD_create_response_from_buffer (strlen (mod_response),
- mod_response,
- MHD_RESPMEM_MUST_COPY));
+ mod_body = json_dumps (parsed_response, JSON_COMPACT);
+
+ hr->mod_response = MHD_create_response_from_buffer
+ (strlen (mod_body),
+ mod_body,
+ MHD_RESPMEM_MUST_COPY);
+ json_decref (parsed_response);
+ delete_path[0] = '\0';
+
+ struct HttpResponseHeader *header;
+ for (header = hr->header_head;
+ NULL != header;
+ header = header->next)
+ GNUNET_break
+ (MHD_YES == MHD_add_response_header (hr->mod_response,
+ header->type,
+ header->value));
+ return MHD_queue_response (con,
+ hr->response_code,
+ hr->mod_response);
}
- /* Response is untouched. */
+
+ /* response might have been modified. */
return MHD_queue_response (con,
hr->response_code,
hr->response);
@@ -1223,6 +1224,11 @@ mhd_completed_cb (void *cls,
hr->curl = NULL;
hr->io_len = 0;
}
+
+ if ((NULL != hr->mod_response))
+ /* Destroy hacked responses. */
+ MHD_destroy_response (hr->mod_response);
+
if ( (NULL != hr->response) &&
(curl_failure_response != hr->response) )
/* Destroy non-error responses... (?) */
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [taler-twister] 10/34: fix object walking., (continued)
- [GNUnet-SVN] [taler-twister] 10/34: fix object walking., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 04/34: parsing proxied responses., gnunet, 2018/03/16
- [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 <=
- [GNUnet-SVN] [taler-twister] 17/34: moving object-killer into helper function., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 18/34: avoid duplicating tokenized string., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 02/34: parse proxied response., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 27/34: fix last path token detection., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 28/34: new-line, gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 33/34: rely again on RNG., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 25/34: make mods cumulative, gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 20/34: option name., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 24/34: add testing-lib command to modify responses., gnunet, 2018/03/16
- [GNUnet-SVN] [taler-twister] 31/34: implement upload data malformation., gnunet, 2018/03/16