http: fix user agent in request

App name is used in HTTP request User-Agent header.

Type: fix

Change-Id: Ib761e8a8e793e04e8d77141cc8c0f8514ed0e547
Signed-off-by: Matus Fabian <matfabia@cisco.com>
This commit is contained in:
Matus Fabian
2024-05-13 11:50:46 +02:00
committed by Florin Coras
parent 05c625f1f6
commit 2516b1ac73

View File

@ -378,7 +378,7 @@ static const char *http_response_template = "HTTP/1.1 %s\r\n"
"Content-Length: %lu\r\n\r\n";
static const char *http_request_template = "GET %s HTTP/1.1\r\n"
"User-Agent: VPP HTTP client\r\n"
"User-Agent: %s\r\n"
"Accept: */*\r\n";
static u32
@ -819,7 +819,7 @@ http_state_wait_app_method (http_conn_t *hc, transport_send_params_t *sp)
rv = svm_fifo_dequeue (as->tx_fifo, msg.data.len, buf);
ASSERT (rv == msg.data.len);
request = format (0, http_request_template, buf);
request = format (0, http_request_template, buf, hc->app_name);
offset = http_send_data (hc, request, vec_len (request), 0);
if (offset != vec_len (request))
{
@ -1157,6 +1157,11 @@ http_transport_connect (transport_endpoint_cfg_t *tep)
hc->state = HTTP_CONN_STATE_CONNECTING;
cargs->api_context = hc_index;
if (vec_len (app->name))
hc->app_name = vec_dup (app->name);
else
hc->app_name = format (0, "VPP HTTP client");
HTTP_DBG (1, "hc ho_index %x", hc_index);
if ((error = vnet_connect (cargs)))