summaryrefslogtreecommitdiff
path: root/src/twister/taler-twister-service.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/twister/taler-twister-service.c')
-rw-r--r--src/twister/taler-twister-service.c74
1 files changed, 72 insertions, 2 deletions
diff --git a/src/twister/taler-twister-service.c b/src/twister/taler-twister-service.c
index 25dea13..4549a52 100644
--- a/src/twister/taler-twister-service.c
+++ b/src/twister/taler-twister-service.c
@@ -344,6 +344,14 @@ static char *modify_path_dl;
*/
static char *modify_path_ul;
+
+/**
+ * If not NULL, the name of the header value to
+ * modify in the response.
+ */
+static char *modify_header_dl;
+
+
/**
* If true, will randomly truncate the request body
* to upload to the proxied service.
@@ -1907,14 +1915,21 @@ create_response (void *cls,
NULL != header;
header = header->next)
{
+ const char *value = header->value;
+ if ((NULL != modify_header_dl) &&
+ (0 == strcmp (header->type,
+ modify_header_dl)))
+ {
+ value = modify_value;
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Adding MHD response header %s->%s\n",
header->type,
- header->value);
+ value);
GNUNET_break
(MHD_YES == MHD_add_response_header (hr->response,
header->type,
- header->value));
+ value));
}
run_mhd_now ();
@@ -2713,6 +2728,56 @@ handle_modify_path_ul (void *cls,
/**
+ * Control handler for changing an HTTP response header.
+ *
+ * @param cls message queue for sending replies
+ * @param src received message
+ */
+static int
+check_modify_header_dl (void *cls,
+ const struct TWISTER_ModifyPath *src)
+{
+ return GNUNET_OK;
+}
+
+
+/**
+ * Control handler for changing an HTTP response header.
+ *
+ * @param cls message queue for sending replies
+ * @param src received message
+ */
+static void
+handle_modify_header_dl (void *cls,
+ const struct TWISTER_ModifyPath *src)
+{
+ struct GNUNET_SERVICE_Client *c = cls;
+ uint16_t tailsize;
+ char *payload_path;
+ char *payload_value;
+
+ tailsize = ntohs (src->header.size) - sizeof (*src);
+
+ if (tailsize != GNUNET_STRINGS_buffer_tokenize
+ ((const char *) &src[1],
+ tailsize,
+ 2,
+ &payload_path,
+ &payload_value))
+ {
+ GNUNET_break_op (0);
+ GNUNET_SERVICE_client_drop (c);
+ return;
+ }
+
+ modify_header_dl = GNUNET_strdup (payload_path);
+ modify_value = GNUNET_strdup (payload_value);
+
+ send_acknowledgement (c);
+}
+
+
+/**
* Control handler for flipping JSON strings into response objects
*
* @param cls message queue for sending replies
@@ -2894,6 +2959,11 @@ GNUNET_SERVICE_MAIN
struct TWISTER_ModifyPath,
NULL),
+ GNUNET_MQ_hd_var_size (modify_header_dl,
+ TWISTER_MESSAGE_TYPE_MODIFY_HEADER_DL,
+ struct TWISTER_ModifyPath,
+ NULL),
+
GNUNET_MQ_hd_fixed_size (malform_upload,
TWISTER_MESSAGE_TYPE_MALFORM_UPLOAD,
struct TWISTER_Malform,