summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2017-03-10 12:11:12 +0100
committerLukas Slebodnik <lslebodn@redhat.com>2017-03-30 19:07:17 +0200
commitd1ed11fc50922aab2332758a9300f3fbf814f112 (patch)
tree3a1d817a98e5578060a26989371c20daed2fec82
parentc2ea75da72b426d98ba489039e220d417bfb4c2a (diff)
downloadsssd-d1ed11fc50922aab2332758a9300f3fbf814f112.tar.gz
sssd-d1ed11fc50922aab2332758a9300f3fbf814f112.tar.xz
sssd-d1ed11fc50922aab2332758a9300f3fbf814f112.zip
tcurl test: allow to set custom headers
Reviewed-by: Simo Sorce <simo@redhat.com> Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
-rw-r--r--src/tests/tcurl_test_tool.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/tests/tcurl_test_tool.c b/src/tests/tcurl_test_tool.c
index 4ceef8e06..63a3e26b5 100644
--- a/src/tests/tcurl_test_tool.c
+++ b/src/tests/tcurl_test_tool.c
@@ -40,6 +40,7 @@ struct tool_options {
int tls;
int verify_peer;
int verify_host;
+ const char **headers;
enum tcurl_http_method method;
const char *socket_path;
@@ -121,13 +122,14 @@ prepare_requests(TALLOC_CTX *mem_ctx,
size_t *_num_requests)
{
struct tcurl_request **requests;
+ struct sss_iobuf *body;
+ const char **headers;
const char *arg;
const char *url;
- struct sss_iobuf *body;
errno_t ret;
size_t i;
- static const char *headers[] = {
+ static const char *default_headers[] = {
"Content-type: application/octet-stream",
NULL,
};
@@ -137,6 +139,8 @@ prepare_requests(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
+ headers = opts->headers == NULL ? default_headers : opts->headers;
+
i = 0;
while ((arg = poptGetArg(pc)) != NULL) {
if (i >= MAXREQ) {
@@ -302,6 +306,9 @@ int main(int argc, const char *argv[])
{ "put", 'p', POPT_ARG_NONE, NULL, 'p', "Perform a HTTP PUT", NULL },
{ "post", 'o', POPT_ARG_NONE, NULL, 'o', "Perform a HTTP POST", NULL },
{ "del", 'd', POPT_ARG_NONE, NULL, 'd', "Perform a HTTP DELETE", NULL },
+#ifdef POPT_ARG_ARGV
+ { "header", 'h', POPT_ARG_ARGV, &opts.headers, '\0', "Add HTTP header", NULL },
+#endif
{ "raw", 'r', POPT_ARG_NONE, &opts.raw, '\0', "Print raw protocol output", NULL },
{ "verbose", 'v', POPT_ARG_NONE, &opts.verbose, '\0', "Print response code and body", NULL },
/* TLS */