From e1d40bf585ef23e24145bee1cd89ae0ab8bc303d Mon Sep 17 00:00:00 2001 From: Adrian Villin Date: Thu, 27 Feb 2025 15:04:56 +0100 Subject: session: uri parsing improvements - It is now possible to use "proto://ip4:port/target" or "proto://[ip6]:port/target" format. - Updated http_client and related tests to use the new format Type: improvement Change-Id: Ic6afd8c66eddca2ab1d7afc034e193441c34f8ee Signed-off-by: Adrian Villin --- src/plugins/hs_apps/http_client.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/hs_apps/http_client.c b/src/plugins/hs_apps/http_client.c index e4759317cbe..4701253bf59 100644 --- a/src/plugins/hs_apps/http_client.c +++ b/src/plugins/hs_apps/http_client.c @@ -693,9 +693,9 @@ hc_get_event (vlib_main_t *vm) { wrk = hc_worker_get (hcm->worker_index); hc_session = hc_session_get (wrk->session_index, wrk->thread_index); - vlib_cli_output (vm, "< %v< %v", hc_session->response_status, - hc_session->resp_headers); - vlib_cli_output (vm, "\n%v\n", hc_session->http_response); + vlib_cli_output (vm, "< %v\n< %v\n%v", hc_session->response_status, + hc_session->resp_headers, + hc_session->http_response); } break; case HC_REPEAT_DONE: @@ -851,8 +851,6 @@ hc_command_fn (vlib_main_t *vm, unformat_input_t *input, ; else if (unformat (line_input, "data %v", &hcm->data)) hcm->is_file = 0; - else if (unformat (line_input, "target %s", &hcm->target)) - ; else if (unformat (line_input, "file %s", &path)) hcm->is_file = 1; else if (unformat (line_input, "use-ptr")) @@ -919,11 +917,7 @@ hc_command_fn (vlib_main_t *vm, unformat_input_t *input, err = clib_error_return (0, "URI not defined"); goto done; } - if (!hcm->target) - { - err = clib_error_return (0, "target not defined"); - goto done; - } + if (!hcm->data && hcm->req_method == HTTP_REQ_POST) { if (path) @@ -939,6 +933,7 @@ hc_command_fn (vlib_main_t *vm, unformat_input_t *input, goto done; } } + if (hcm->duration && hcm->repeat_count) { err = clib_error_return ( @@ -953,6 +948,13 @@ hc_command_fn (vlib_main_t *vm, unformat_input_t *input, goto done; } + if ((rv = parse_target ((char **) &hcm->uri, (char **) &hcm->target))) + { + err = clib_error_return (0, "target parse error: %U", + format_session_error, rv); + goto done; + } + if ((rv = parse_uri ((char *) hcm->uri, &hcm->connect_sep))) { err = @@ -1000,7 +1002,7 @@ done: VLIB_CLI_COMMAND (hc_command, static) = { .path = "http client", .short_help = - "[post] uri http:// target " + "[post] uri http:/// " "[data | file ] [use-ptr] " "[save-to ] [header ] [verbose] " "[timeout (default = 10)] [repeat | duration ] " -- cgit