Blame SOURCES/0079-tcurl-test-allow-to-set-custom-headers.patch

ecf709
From 8047207b470ea417b11919e84931a751485d2326 Mon Sep 17 00:00:00 2001
ecf709
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
ecf709
Date: Fri, 10 Mar 2017 12:11:12 +0100
ecf709
Subject: [PATCH 79/90] tcurl test: allow to set custom headers
ecf709
ecf709
Reviewed-by: Simo Sorce <simo@redhat.com>
ecf709
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
ecf709
(cherry picked from commit d1ed11fc50922aab2332758a9300f3fbf814f112)
ecf709
---
ecf709
 src/tests/tcurl_test_tool.c | 11 +++++++++--
ecf709
 1 file changed, 9 insertions(+), 2 deletions(-)
ecf709
ecf709
diff --git a/src/tests/tcurl_test_tool.c b/src/tests/tcurl_test_tool.c
ecf709
index 4ceef8e06040ea0abd4d112a5b7845f436c69488..63a3e26b561781795873c2a4d72ac071a4da9939 100644
ecf709
--- a/src/tests/tcurl_test_tool.c
ecf709
+++ b/src/tests/tcurl_test_tool.c
ecf709
@@ -40,6 +40,7 @@ struct tool_options {
ecf709
     int tls;
ecf709
     int verify_peer;
ecf709
     int verify_host;
ecf709
+    const char **headers;
ecf709
 
ecf709
     enum tcurl_http_method method;
ecf709
     const char *socket_path;
ecf709
@@ -121,13 +122,14 @@ prepare_requests(TALLOC_CTX *mem_ctx,
ecf709
                  size_t *_num_requests)
ecf709
 {
ecf709
     struct tcurl_request **requests;
ecf709
+    struct sss_iobuf *body;
ecf709
+    const char **headers;
ecf709
     const char *arg;
ecf709
     const char *url;
ecf709
-    struct sss_iobuf *body;
ecf709
     errno_t ret;
ecf709
     size_t i;
ecf709
 
ecf709
-    static const char *headers[] = {
ecf709
+    static const char *default_headers[] = {
ecf709
         "Content-type: application/octet-stream",
ecf709
         NULL,
ecf709
     };
ecf709
@@ -137,6 +139,8 @@ prepare_requests(TALLOC_CTX *mem_ctx,
ecf709
         return ENOMEM;
ecf709
     }
ecf709
 
ecf709
+    headers = opts->headers == NULL ? default_headers : opts->headers;
ecf709
+
ecf709
     i = 0;
ecf709
     while ((arg = poptGetArg(pc)) != NULL) {
ecf709
         if (i >= MAXREQ) {
ecf709
@@ -302,6 +306,9 @@ int main(int argc, const char *argv[])
ecf709
         { "put", 'p', POPT_ARG_NONE, NULL, 'p', "Perform a HTTP PUT", NULL },
ecf709
         { "post", 'o', POPT_ARG_NONE, NULL, 'o', "Perform a HTTP POST", NULL },
ecf709
         { "del", 'd', POPT_ARG_NONE, NULL, 'd', "Perform a HTTP DELETE", NULL },
ecf709
+#ifdef POPT_ARG_ARGV
ecf709
+        { "header", 'h', POPT_ARG_ARGV, &opts.headers, '\0', "Add HTTP header", NULL },
ecf709
+#endif
ecf709
         { "raw", 'r', POPT_ARG_NONE, &opts.raw, '\0', "Print raw protocol output", NULL },
ecf709
         { "verbose", 'v', POPT_ARG_NONE, &opts.verbose, '\0', "Print response code and body", NULL },
ecf709
         /* TLS */
ecf709
-- 
ecf709
2.9.3
ecf709