MINOR: flags/http_ana: use flag dumping to show http msg states

The function is hmsg_show_flags(). It shows the HTTP_MSGF_* flags.
This commit is contained in:
Willy Tarreau 2022-09-09 17:18:57 +02:00
parent 5349779e40
commit 6edae6ff48
2 changed files with 25 additions and 2 deletions

View File

@ -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<<i.
const char *show_as_words[] = { "ana", "chn", "conn", "sc", "stet", "strm", "task", "txn", "sd", "hsl", "htx", };
const char *show_as_words[] = { "ana", "chn", "conn", "sc", "stet", "strm", "task", "txn", "sd", "hsl", "htx", "hmsg", };
/* will be sufficient for even largest flag names */
static char buf[4096];
@ -129,6 +130,7 @@ int main(int argc, char **argv)
if (show_as & SHOW_AS_TXN) printf("txn->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;
}

View File

@ -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