aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/http/http_test.c
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2024-08-08 12:50:32 +0200
committerFlorin Coras <florin.coras@gmail.com>2024-08-09 20:08:59 +0000
commitd58177c50bb36a712c645fe8c13d126ebadbdc7f (patch)
tree00bfe91f7b98b9aa8b753123e5dc6883c2c4a676 /src/plugins/http/http_test.c
parent0ce93ae744453139aa6a6ba8f55415c214f0d972 (diff)
http: authority-form target parsing/serializing
Type: improvement Change-Id: Ifb90818a3526d3d4030a66b1ef7eebedfe97978f Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/http/http_test.c')
-rw-r--r--src/plugins/http/http_test.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/plugins/http/http_test.c b/src/plugins/http/http_test.c
new file mode 100644
index 00000000000..1f2f21dd19a
--- /dev/null
+++ b/src/plugins/http/http_test.c
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: Apache-2.0
+ * Copyright(c) 2024 Cisco Systems, Inc.
+ */
+
+#include <http/http.h>
+
+static clib_error_t *
+test_http_authority_command_fn (vlib_main_t *vm, unformat_input_t *input,
+ vlib_cli_command_t *cmd)
+{
+ u8 *target = 0;
+ http_uri_t authority;
+ int rv;
+
+ if (!unformat (input, "%v", &target))
+ return clib_error_return (0, "error: no input provided");
+
+ rv = http_parse_authority_form_target (target, &authority);
+ vec_free (target);
+ if (rv)
+ return clib_error_return (0, "error: parsing failed");
+
+ target = http_serialize_authority_form_target (&authority);
+ vlib_cli_output (vm, "%v", target);
+ vec_free (target);
+
+ return 0;
+}
+
+VLIB_CLI_COMMAND (test_http_authority_command) = {
+ .path = "test http authority-form",
+ .short_help = "test dns authority-form",
+ .function = test_http_authority_command_fn,
+};