From: Willy Tarreau Date: Fri, 9 Sep 2022 15:18:57 +0000 (+0200) Subject: MINOR: flags/http_ana: use flag dumping to show http msg states X-Git-Tag: v2.7-dev6~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6edae6ff482ac23e3a3ca7a40ef4558237b0cfd0;p=thirdparty%2Fhaproxy.git MINOR: flags/http_ana: use flag dumping to show http msg states The function is hmsg_show_flags(). It shows the HTTP_MSGF_* flags. --- diff --git a/dev/flags/flags.c b/dev/flags/flags.c index 1afa9a9e2c..ac933e252a 100644 --- a/dev/flags/flags.c +++ b/dev/flags/flags.c @@ -21,10 +21,11 @@ #define SHOW_AS_SD 0x00000100 #define SHOW_AS_HSL 0x00000200 #define SHOW_AS_HTX 0x00000400 +#define SHOW_AS_HMSG 0x00000800 // command line names, must be in exact same order as the SHOW_AS_* flags above // so that show_as_words[i] matches flag 1U<flags = %s\n", (txn_show_flags (buf, bsz, " | ", flags), buf)); if (show_as & SHOW_AS_HSL) printf("sl->flags = %s\n", (hsl_show_flags (buf, bsz, " | ", flags), buf)); if (show_as & SHOW_AS_HTX) printf("htx->flags = %s\n", (htx_show_flags (buf, bsz, " | ", flags), buf)); + if (show_as & SHOW_AS_HMSG) printf("hmsg->flags = %s\n", (hmsg_show_flags (buf, bsz, " | ", flags), buf)); } return 0; } diff --git a/include/haproxy/http_ana-t.h b/include/haproxy/http_ana-t.h index 735a2fbaa4..b9d65ec3b0 100644 --- a/include/haproxy/http_ana-t.h +++ b/include/haproxy/http_ana-t.h @@ -110,7 +110,8 @@ static forceinline char *txn_show_flags(char *buf, size_t len, const char *delim /* - * HTTP message status flags (msg->flags) + * HTTP message status flags (msg->flags). + * Please also update the txn_show_flags() function below in case of changes. */ #define HTTP_MSGF_CNT_LEN 0x00000001 /* content-length was found in the message */ #define HTTP_MSGF_TE_CHNK 0x00000002 /* transfer-encoding: chunked was found */ @@ -129,6 +130,26 @@ static forceinline char *txn_show_flags(char *buf, size_t len, const char *delim #define HTTP_MSGF_BODYLESS 0x00000040 /* The message has no body (content-length = 0) */ #define HTTP_MSGF_CONN_UPG 0x00000080 /* The message contains "Connection: Upgrade" header */ +/* This function is used to report flags in debugging tools. Please reflect + * below any single-bit flag addition above in the same order via the + * __APPEND_FLAG macro. The new end of the buffer is returned. + */ +static forceinline char *hmsg_show_flags(char *buf, size_t len, const char *delim, uint flg) +{ +#define _(f, ...) __APPEND_FLAG(buf, len, delim, flg, f, #f, __VA_ARGS__) + /* prologue */ + _(0); + /* flags */ + _(HTTP_MSGF_CNT_LEN, _(HTTP_MSGF_TE_CHNK, _(HTTP_MSGF_XFER_LEN, + _(HTTP_MSGF_VER_11, _(HTTP_MSGF_SOFT_RW, _(HTTP_MSGF_COMPRESSING, + _(HTTP_MSGF_BODYLESS, _(HTTP_MSGF_CONN_UPG)))))))); + /* epilogue */ + _(~0U); + return buf; +#undef _ +} + + /* Maximum length of the cache secondary key (sum of all the possible parts of * the secondary key). The actual keys might be smaller for some * request/response pairs, because they depend on the responses' optional Vary