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 1afa9a9..ac933e2 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<<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 @@
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;
}
diff --git a/include/haproxy/http_ana-t.h b/include/haproxy/http_ana-t.h
index 735a2fb..b9d65ec 100644
--- a/include/haproxy/http_ana-t.h
+++ b/include/haproxy/http_ana-t.h
@@ -110,7 +110,8 @@
/*
- * 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 @@
#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