From: Miroslav Zagorac Date: Wed, 8 Sep 2021 23:23:42 +0000 (+0200) Subject: BUG/MINOR: opentracing: enable the use of http headers without a set value X-Git-Tag: v2.5-dev7~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=71cb1ab6b9bc4aa0405df0ab2447430eb3402bdc;p=thirdparty%2Fhaproxy.git BUG/MINOR: opentracing: enable the use of http headers without a set value In case we transfer some data that does not have a set value via the HTTP header, adding that header in the text map was done incorrectly. This simple patch allows the use of HTTP headers without a set value. --- diff --git a/addons/ot/src/http.c b/addons/ot/src/http.c index 4a12ed854b..1517e71e48 100644 --- a/addons/ot/src/http.c +++ b/addons/ot/src/http.c @@ -139,8 +139,14 @@ struct otc_text_map *flt_ot_http_headers_get(struct channel *chn, const char *pr * * Before adding, the prefix is removed from the * HTTP header name. + * + * In case the data of the HTTP header is not + * specified, v.len will be equal to 0, and + * the function otc_text_map_add() will not + * interpret this well. In this case, instead + * of v.ptr, "" is used. */ - if (otc_text_map_add(retptr, n.ptr + prefix_len, n.len - prefix_len, v.ptr, v.len, OTC_TEXT_MAP_DUP_KEY | OTC_TEXT_MAP_DUP_VALUE) == -1) { + if (otc_text_map_add(retptr, n.ptr + prefix_len, n.len - prefix_len, (v.len > 0) ? v.ptr : "", v.len, OTC_TEXT_MAP_DUP_KEY | OTC_TEXT_MAP_DUP_VALUE) == -1) { FLT_OT_ERR("failed to add HTTP header data"); otc_text_map_destroy(&retptr, OTC_TEXT_MAP_FREE_KEY | OTC_TEXT_MAP_FREE_VALUE);