diff options
author | 2025-02-27 15:04:56 +0100 | |
---|---|---|
committer | 2025-03-03 19:20:46 +0000 | |
commit | e1d40bf585ef23e24145bee1cd89ae0ab8bc303d (patch) | |
tree | 7a9bbcf1773f4fc5cdb4f3d992f4842ea202df75 /src/plugins | |
parent | 9c948e4d2a71269acffa634b3c6b2741d558cee0 (diff) |
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 <avillin@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/hs_apps/http_client.c | 24 |
1 files changed, 13 insertions, 11 deletions
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://<ip-addr> target <origin-form> " + "[post] uri http://<ip-addr>/<origin-form> " "[data <form-urlencoded> | file <file-path>] [use-ptr] " "[save-to <filename>] [header <Key:Value>] [verbose] " "[timeout <seconds> (default = 10)] [repeat <count> | duration <seconds>] " |