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

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